Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
rjiovanni  
#1 Posted : Friday, May 4, 2012 5:09:46 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

Hi, i am using VB6+eagetmail+Access2002 to download e-mails, but i dont want to use EML files to read then everytime.
How can i save my emails and retrieve it from my 'database'? What about the attachments?

thanks.
ivan  
#2 Posted : Friday, May 4, 2012 5:53:35 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:
Hi, i am using VB6+eagetmail+Access2002 to download e-mails, but i dont want to use EML files to read then everytime.
How can i save my emails and retrieve it from my 'database'? What about the attachments?

thanks.


Hi, you can save Mail.Content (binary array) to access database as OLE object data type.

Then when you want to read it, please read the binary data from access and use

Mail.Load method to load it back to Mail object.

With above methods, Attachments will be saved/loaded as well.
rjiovanni  
#3 Posted : Saturday, May 5, 2012 5:31:48 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

Ohhh, thnks for the tip ... i will try it.
rjiovanni  
#4 Posted : Monday, May 7, 2012 12:17:19 PM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

Okay, i saved the binary as you say without problems, but i cant retrieve it, check my code please:

Saving binary:

...
rs!email = oMail.Content 'email field = data type OLE Object on Access2002
...

Open binary

oMail.Load rs!email

i got that error:

-2147024809: NativeErrorCode: 87[DATA]

What i am doing wrong here?

Thanks.
ivan  
#5 Posted : Monday, May 7, 2012 4:39:19 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:
Okay, i saved the binary as you say without problems, but i cant retrieve it, check my code please:

Saving binary:

...
rs!email = oMail.Content 'email field = data type OLE Object on Access2002
...

Open binary

oMail.Load rs!email

i got that error:

-2147024809: NativeErrorCode: 87[DATA]

What i am doing wrong here?

Thanks.


Hi, you should use AppendChunk and GetChunk method to access the binary data.

Please tell me what database object you used? DAO or ADO.
Then I will give you the example code.
ivan  
#6 Posted : Monday, May 7, 2012 5:13:57 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:
Okay, i saved the binary as you say without problems, but i cant retrieve it, check my code please:

Saving binary:

...
rs!email = oMail.Content 'email field = data type OLE Object on Access2002
...

Open binary

oMail.Load rs!email

i got that error:

-2147024809: NativeErrorCode: 87[DATA]

What i am doing wrong here?

Thanks.


Here is a DAO example:

mail_data = oMail.Content

rs!email_size = LenB( mail_data ) 'please add a number field in your table to store the binary data size.
rs!email = mail_data

then when you load it back, please use the following code:

mail_len = rs!email_size
mail_data = rs!email.GetChunk(0, mail_len)
oMail.Load mail_data
rjiovanni  
#7 Posted : Tuesday, May 8, 2012 3:30:25 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

I am using ADO ...
ivan  
#8 Posted : Tuesday, May 8, 2012 4:26:35 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:
I am using ADO ...



Here is a DAO example:

mail_data = oMail.Content

rs!email_size = LenB( mail_data ) 'please add a number field in your table to store the binary data size.
rs!email = mail_data

then when you load it back, please use the following code:

mail_len = rs!email_size
mail_data = rs!email.GetChunk(0, mail_len)
oMail.Load mail_data
rjiovanni  
#9 Posted : Wednesday, May 9, 2012 4:50:44 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

Perfect m8, thanks for the tip, i neve work before with binary, never had to. ehehehhe
rjiovanni  
#10 Posted : Wednesday, May 9, 2012 7:33:42 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

Can i send the same e-mail using his "content" field?

Or i must create a temp eml file to send an e-mail?

I did a sample using the eml file do load the email to the object and send it, but i had a problem with the subject property, didn´t work with the "new subject", i change the original one.

Great component.

Edited by user Wednesday, May 9, 2012 3:09:56 PM(UTC)  | Reason: Not specified

ivan  
#11 Posted : Wednesday, May 9, 2012 4:18:33 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:
Can i send the same e-mail using his "content" field?

Or i must create a temp eml file to send an e-mail?

I did a sample using the eml file do load the email to the object and send it, but i had a problem with the subject property, didn´t work with the "new subject", i change the original one.

Great component.


Are you using EASendMail to send email? could you show me your code?

rjiovanni  
#12 Posted : Thursday, May 10, 2012 3:39:26 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

Code:

    'zera atributos
    m_oSmtp.Reset  'because m_oSmtp is a member variahle, so we need to clear the the property
    m_oSmtp.Asynchronous = 1
    m_oSmtp.ServerAddr = ""
    m_oSmtp.ServerPort = 25
    m_oSmtp.SSL_uninit
    m_oSmtp.UserName = ""
    m_oSmtp.Password = ""
    
    m_oSmtp.ServerAddr = sServidor_SMTP
    m_oSmtp.Protocol = rs!protocolo_envio
    
    If sServidor_SMTP <> "" Then
        If rs!autenticacao_requerida Then
            m_oSmtp.UserName = rs!usuario
            m_oSmtp.Password = rs!senha
        End If
        
        If rs!autenticacao_ssl Then
            If m_oSmtp.SSL_init() <> 0 Then
                MsgBox ("Falha ao carregar a biblioteca SSL!")  'failed to load SSL library
                Exit Function
            End If
            'If SSL port is 465 or other port rather than 25 port, please use
            'm_oSmtp.ServerPort = 465
            'm_oSmtp.SSL_starttls = 0
        End If
    End If
    
    m_oSmtp.Charset = rs!encoding 'm_arCharset(24, 1)
    Dim name, addr As String
    fnParseAddr psEmailDe, name, addr
    
    'Using this email to be replied to another address
    'm_oSmtp.ReplyTo = ReplyAddress
    
    m_oSmtp.From = name
    m_oSmtp.FromAddr = addr
    
    'add digital signature
    m_oSmtp.SignerCert.Unload
    
    If rs!assinatura_digital Then
        If Not m_oSmtp.SignerCert.FindSubject(addr, CERT_SYSTEM_STORE_CURRENT_USER, "my") Then
            MsgBox m_oSmtp.SignerCert.GetLastError() & ":" & addr
'            btnSend.Enabled = True
            btnCancel.Enabled = False
        Exit Function
        End If
        If Not m_oSmtp.SignerCert.HasPrivateKey Then
            MsgBox "O certificado não possui chave privada, portanto não poderá ser usado na assinatura deste E-mail!" '"Signer certificate has not private key, this certificate can not be used to sign email!"
'            btnSend.Enabled = True
            btnCancel.Enabled = False
            Exit Function
        End If
    End If
    
    m_oSmtp.AddRecipientEx psEmailPara, 0  ' 0, Normal recipient, 1, cc, 2, bcc
    m_oSmtp.AddRecipientEx sEndereco_cc, 0
    
    Dim recipients As String
    recipients = psEmailPara & "," & sEndereco_cc
    fnTrim recipients, ","
    
    Dim i, Count As Integer
    'encrypt email by recipients certificate
    m_oSmtp.RecipientsCerts.Clear
    If rs!criptografar Then
        Dim arAddr
        arAddr = SplitEx(recipients, ",")   'split the multiple address to an array
        Count = UBound(arAddr)
        For i = LBound(arAddr) To Count
            addr = arAddr(i)
            fnTrim addr, " ,;"
            If addr <> "" Then
                'find the encrypting certificate for every recipients
                Dim oEncryptCert As New EASendMailObjLib.Certificate
                If Not oEncryptCert.FindSubject(addr, CERT_SYSTEM_STORE_CURRENT_USER, "AddressBook") Then
                    If Not oEncryptCert.FindSubject(addr, CERT_SYSTEM_STORE_CURRENT_USER, "my") Then
                        MsgBox oEncryptCert.GetLastError() & ":" & addr
'                        btnSend.Enabled = True
                        btnCancel.Enabled = False
                        Exit Function
                    End If
                End If
                m_oSmtp.RecipientsCerts.Add oEncryptCert
            End If
        Next
    End If
    
    Count = UBound(m_arAttachment)
    For i = 0 To Count - 1
        If m_oSmtp.AddAttachment(m_arAttachment(i)) <> 0 Then
            MsgBox m_oSmtp.GetLastErrDescription() & ":" & m_arAttachment(i)
'            btnSend.Enabled = True
            btnCancel.Enabled = False
            Exit Function
        End If
    Next
    
    'Salva arquivo de email com base no database (EML e HTML)  <<<<<<<<<<<<<<<<<<<<<< SAVE EML and HTML File
    If Not eMail_Salvar_EML(pId_Email, sPath_Arq_EML, sPath_Arq_HTML) Then
        Atencao "Ocorreram erros na geração do arquivo EML! Verique as permissões da pasta " & pPathEmails
        Exit Function
    End If
    
    ' Load EML file to body text temporally  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< import Mail
    m_oSmtp.ImportMail sPath_Arq_EML
    ' Assign Eml file data to raw content  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< load raw_Content
    m_oSmtp.raw_Content = m_oSmtp.BodyText
    
    m_oSmtp.BodyFormat = 1    ' Using HTML FORMAT to send mail
    
    m_oSmtp.Subject = psAssunto  '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NEW SUBJECT 
    
    'm_oSmtp.
    
    If InStr(1, recipients, ",", 1) > 1 And sServidor_SMTP = "" Then
        'To send email without specified smtp server, we have to send the emails one by one
        ' to multiple recipients. That is because every recipient has different smtp server.
        DirectSend m_oSmtp, recipients
        
        btnCancel.Enabled = False
        textStatus.SimpleText = ""
        Exit Function
    End If
    
    textStatus.SimpleText = "Conectando " & sServidor_SMTP & " ..."
    m_bIdle = False
    m_bCancel = False
    m_bError = False
    pgBar.Value = 0
    
    m_oSmtp.SendMail
    
    'wait the asynchronous call finish.
    Do While Not m_bIdle
        DoEvents
    Loop

Edited by user Thursday, May 10, 2012 3:40:03 AM(UTC)  | Reason: Not specified

ivan  
#13 Posted : Thursday, May 10, 2012 4:03:39 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:
Code:

    'zera atributos
    m_oSmtp.Reset  'because m_oSmtp is a member variahle, so we need to clear the the property
    m_oSmtp.Asynchronous = 1
    m_oSmtp.ServerAddr = ""
    m_oSmtp.ServerPort = 25
    m_oSmtp.SSL_uninit
    m_oSmtp.UserName = ""
    m_oSmtp.Password = ""
    
    m_oSmtp.ServerAddr = sServidor_SMTP
    m_oSmtp.Protocol = rs!protocolo_envio
    
    If sServidor_SMTP <> "" Then
        If rs!autenticacao_requerida Then
            m_oSmtp.UserName = rs!usuario
            m_oSmtp.Password = rs!senha
        End If
        
        If rs!autenticacao_ssl Then
            If m_oSmtp.SSL_init() <> 0 Then
                MsgBox ("Falha ao carregar a biblioteca SSL!")  'failed to load SSL library
                Exit Function
            End If
            'If SSL port is 465 or other port rather than 25 port, please use
            'm_oSmtp.ServerPort = 465
            'm_oSmtp.SSL_starttls = 0
        End If
    End If
    
    m_oSmtp.Charset = rs!encoding 'm_arCharset(24, 1)
    Dim name, addr As String
    fnParseAddr psEmailDe, name, addr
    
    'Using this email to be replied to another address
    'm_oSmtp.ReplyTo = ReplyAddress
    
    m_oSmtp.From = name
    m_oSmtp.FromAddr = addr
    
    'add digital signature
    m_oSmtp.SignerCert.Unload
    
    If rs!assinatura_digital Then
        If Not m_oSmtp.SignerCert.FindSubject(addr, CERT_SYSTEM_STORE_CURRENT_USER, "my") Then
            MsgBox m_oSmtp.SignerCert.GetLastError() & ":" & addr
'            btnSend.Enabled = True
            btnCancel.Enabled = False
        Exit Function
        End If
        If Not m_oSmtp.SignerCert.HasPrivateKey Then
            MsgBox "O certificado não possui chave privada, portanto não poderá ser usado na assinatura deste E-mail!" '"Signer certificate has not private key, this certificate can not be used to sign email!"
'            btnSend.Enabled = True
            btnCancel.Enabled = False
            Exit Function
        End If
    End If
    
    m_oSmtp.AddRecipientEx psEmailPara, 0  ' 0, Normal recipient, 1, cc, 2, bcc
    m_oSmtp.AddRecipientEx sEndereco_cc, 0
    
    Dim recipients As String
    recipients = psEmailPara & "," & sEndereco_cc
    fnTrim recipients, ","
    
    Dim i, Count As Integer
    'encrypt email by recipients certificate
    m_oSmtp.RecipientsCerts.Clear
    If rs!criptografar Then
        Dim arAddr
        arAddr = SplitEx(recipients, ",")   'split the multiple address to an array
        Count = UBound(arAddr)
        For i = LBound(arAddr) To Count
            addr = arAddr(i)
            fnTrim addr, " ,;"
            If addr <> "" Then
                'find the encrypting certificate for every recipients
                Dim oEncryptCert As New EASendMailObjLib.Certificate
                If Not oEncryptCert.FindSubject(addr, CERT_SYSTEM_STORE_CURRENT_USER, "AddressBook") Then
                    If Not oEncryptCert.FindSubject(addr, CERT_SYSTEM_STORE_CURRENT_USER, "my") Then
                        MsgBox oEncryptCert.GetLastError() & ":" & addr
'                        btnSend.Enabled = True
                        btnCancel.Enabled = False
                        Exit Function
                    End If
                End If
                m_oSmtp.RecipientsCerts.Add oEncryptCert
            End If
        Next
    End If
    
    Count = UBound(m_arAttachment)
    For i = 0 To Count - 1
        If m_oSmtp.AddAttachment(m_arAttachment(i)) <> 0 Then
            MsgBox m_oSmtp.GetLastErrDescription() & ":" & m_arAttachment(i)
'            btnSend.Enabled = True
            btnCancel.Enabled = False
            Exit Function
        End If
    Next
    
    'Salva arquivo de email com base no database (EML e HTML)  <<<<<<<<<<<<<<<<<<<<<< SAVE EML and HTML File
    If Not eMail_Salvar_EML(pId_Email, sPath_Arq_EML, sPath_Arq_HTML) Then
        Atencao "Ocorreram erros na geração do arquivo EML! Verique as permissões da pasta " & pPathEmails
        Exit Function
    End If
    
    ' Load EML file to body text temporally  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< import Mail
    m_oSmtp.ImportMail sPath_Arq_EML
    ' Assign Eml file data to raw content  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< load raw_Content
    m_oSmtp.raw_Content = m_oSmtp.BodyText
    
    m_oSmtp.BodyFormat = 1    ' Using HTML FORMAT to send mail
    
    m_oSmtp.Subject = psAssunto  '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NEW SUBJECT 
    
    'm_oSmtp.
    
    If InStr(1, recipients, ",", 1) > 1 And sServidor_SMTP = "" Then
        'To send email without specified smtp server, we have to send the emails one by one
        ' to multiple recipients. That is because every recipient has different smtp server.
        DirectSend m_oSmtp, recipients
        
        btnCancel.Enabled = False
        textStatus.SimpleText = ""
        Exit Function
    End If
    
    textStatus.SimpleText = "Conectando " & sServidor_SMTP & " ..."
    m_bIdle = False
    m_bCancel = False
    m_bError = False
    pgBar.Value = 0
    
    m_oSmtp.SendMail
    
    'wait the asynchronous call finish.
    Do While Not m_bIdle
        DoEvents
    Loop



Hi, if you want to edit the subject, then you should not use raw_Content property.

you should use LoadMessage method
from:
' Load EML file to body text temporally <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< import Mail
m_oSmtp.ImportMail sPath_Arq_EML
' Assign Eml file data to raw content <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< load raw_Content
m_oSmtp.raw_Content = m_oSmtp.BodyText

m_oSmtp.BodyFormat = 1 ' Using HTML FORMAT to send mail

change it to:

' Load EML file to body text temporally <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< import Mail
m_oSmtp.LoadMessage sPath_Arq_EML

m_oSmtp.BodyFormat = 1
rjiovanni  
#14 Posted : Thursday, May 10, 2012 7:16:41 AM(UTC)
rjiovanni

Rank: Newbie

Groups: Registered
Joined: 5/4/2012(UTC)
Posts: 8
Location: BRAZIL - SP

I got this error now:

UserPostedImage

Code:

    m_oSmtp.LoadMessage sPath_Arq_EML


    ' Load EML file to body text temporally
    ' m_oSmtp.ImportMail sPath_Arq_EML
    ' Assign Eml file data to raw content
    ' m_oSmtp.raw_Content = m_oSmtp.BodyText
    
    m_oSmtp.BodyFormat = 1    ' Using HTML FORMAT to send mail
    
    m_oSmtp.Subject = psAssunto
    


When i uncomment the old lines, the email will be send ok, except for the subject...

Edited by user Thursday, May 10, 2012 7:17:35 AM(UTC)  | Reason: Not specified

ivan  
#15 Posted : Thursday, May 10, 2012 6:31:42 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,153

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
rjiovanni wrote:

When i uncomment the old lines, the email will be send ok, except for the subject...


with raw_Content, you cannot edit anything of the email.

please generate a log file with LoadMessage and raw_Content and send it to support@emailarchitect.net so that I can have a check.

m_oSmtp.Subject = psAssunto
m_oSmtp.LogFileName = "d:\smtp.txt"
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.213 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.