Comments on: Download emails with SQLServer https://www.limilabs.com/blog/download-emails-with-sqlserver Using Limilabs .net components Fri, 09 Sep 2016 08:35:13 +0000 hourly 1 https://wordpress.org/?v=6.6.5 By: Limilabs support https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-602910 Wed, 09 Apr 2014 12:20:31 +0000 http://www.limilabs.com/blog/?p=1106#comment-602910 In reply to Dushyant.

@Dushyant,

Have you created this assembly, compiled it? Is the file in this folder. Does your SQL have enough permissions to read this file?

]]>
By: Dushyant https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-602896 Wed, 09 Apr 2014 10:09:31 +0000 http://www.limilabs.com/blog/?p=1106#comment-602896 In the stored procedure I am recieving the following error:

Msg 6501, Level 16, State 7, Line 1
CREATE ASSEMBLY failed because it could not open the physical file “D:\1\SqlEmailDownloader\bin\Debug\SqlEmailDownloader.dll”: 3(failed to retrieve text for this error. Reason: 15105).
Msg 6528, Level 16, State 1, Procedure GetEmails, Line 2
Assembly ‘SqlEmailDownloaderAssembly’ was not found in the SQL catalog of database ‘HelloWorld’.
Msg 2812, Level 16, State 62, Line 2
Could not find stored procedure ‘GetEmail’.

]]>
By: Limilabs support https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-532493 Fri, 19 Apr 2013 14:59:33 +0000 http://www.limilabs.com/blog/?p=1106#comment-532493 In reply to jesil james.

@Jesil

You simply can not connect. You are using incorrect server address or/and port number or your server is down. This connection attempt failed article may help you.

]]>
By: jesil james https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-531169 Thu, 18 Apr 2013 19:28:34 +0000 http://www.limilabs.com/blog/?p=1106#comment-531169 I am getting the Following error in SQL Server when I run the procedure

Msg 6522, Level 16, State 1, Procedure GetEmails1, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate “GetEmails1”:
Limilabs.Client.ServerException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.134.108:143 […]

]]>
By: jesil james https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-529813 Wed, 17 Apr 2013 20:59:25 +0000 http://www.limilabs.com/blog/?p=1106#comment-529813 Sorry the above error was fixed which was a.net framwork issue. which i changed it to 3.5. Now when I am running the SP, I am getting the error -Could not find Type ‘StoredProcedures’ in assembly ‘SqlEmailDownloader’.

]]>
By: jesil james https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-529801 Wed, 17 Apr 2013 20:32:26 +0000 http://www.limilabs.com/blog/?p=1106#comment-529801 I also get an error when i run the sql query ..the error is
CREATE ASSEMBLY for assembly ‘Email_SQL’ failed because the assembly is built for an unsupported version of the Common Language Runtime

]]>
By: Limilabs support https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-485563 Mon, 04 Mar 2013 13:46:11 +0000 http://www.limilabs.com/blog/?p=1106#comment-485563 In reply to Mike.

@Mike

What error do you get? What is the exception message, stack trace?
Can you enable logging?

]]>
By: Mike https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-472876 Fri, 22 Feb 2013 15:18:53 +0000 http://www.limilabs.com/blog/?p=1106#comment-472876 Just having some problems. I have created my DLL based of yours but i get an error message when i run the sql query to create the stored procedure.
Here is my code bellow

Imports System.Data
Imports Microsoft.SqlServer.Server
Imports Limilabs.Client.IMAP
Imports Limilabs.Mail
Public Class Class1
        <Microsoft.SqlServer.Server.SqlProcedure> _
        Public Shared Sub GetEmails()
            Dim record As New SqlDataRecord({ _
                New SqlMetaData("UID", SqlDbType.BigInt), _
                New SqlMetaData("Subject", SqlDbType.NVarChar, 128)})

            Using client As New Imap()
                client.ConnectSSL("Imap.gmail.com")
                client.Login("username", "password")
                client.SelectInbox()

                SqlContext.Pipe.SendResultsStart(record)
                For Each uid As Long In client.Search(Flag.Unseen)
                    Dim eml = client.PeekHeadersByUID(uid)
                    Dim email As IMail = New MailBuilder() _
                    .CreateFromEml(eml)

                    record.SetSqlInt64(0, uid)
                    record.SetSqlString(1, email.Subject)
                    SqlContext.Pipe.SendResultsRow(record)
                Next
                client.Close()
                SqlContext.Pipe.SendResultsEnd()
            End Using
        End Sub
    End Class

Here is the query

USE HelloWorld
GO
EXEC sp_configure 'clr enabled' , '1'

GO

RECONFIGURE

GO
Alter Database HelloWorld Set TrustWorthy On

GO
CREATE ASSEMBLY [System.Windows.Forms] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll'
With Permission_Set=Unsafe

GO

CREATE ASSEMBLY SqlEmailDownloaderAssembly FROM 'E:\mail\SqlEmailDownloader.dll'

With Permission_Set=Unsafe

GO

CREATE PROCEDURE GetEmails

AS EXTERNAL NAME SqlEmailDownloaderAssembly.Class1.GetEmails

GO

Thanks
Mike

]]>
By: Limilabs support https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-52189 Thu, 04 Oct 2012 18:51:06 +0000 http://www.limilabs.com/blog/?p=1106#comment-52189 In reply to Bill Stickers.

@Bill

In our practice the most important thing is to save the original, raw eml data for later reference.

True it takes space, but if you have raw data, at any point of time,
you can check S/MIME digital signatures, DKIM signatures, and
if you forgot to include some important detail in your DB structure,
you are able to recreate it from original data.

As for the DB structure we can’t give you any good advice,
as it greatly depends on what are you planning to do with the data:
Searching? Are attachments important? Do attachments need to be searchable?
Are there any headers that are specially important to you?

]]>
By: Bill Stickers https://www.limilabs.com/blog/download-emails-with-sqlserver#comment-51685 Thu, 04 Oct 2012 14:14:36 +0000 http://www.limilabs.com/blog/?p=1106#comment-51685 I think it is pretty common to want to download emails and store them in a database. Is there a preferred way to do this for mail.dll or a recommended ADO model structure which corresponds to the IMail interface?

]]>