LoadRawMessage Method


Load email from a *.EML file to raw_Content property and send it with 100% original format.

[Syntax]
Visual C++: HRESULT LoadRawMessage( BSTR FileName, LONG Flag, long* pVal )
Visual Basic: LoadRawMessage( FileName As String, LONG Flag ) As Long

Parameters

FileName
The full path of the email file to load.
Flag
If this value is zero, this method only loads the email content; If this value is 1, this method also parses From, Reply-to, Recipients and load it to current mail object.

Return Value

If this method succeeds, the return value is zero; otherwise the return value is non-zero.

Remarks

This method is different with LoadMessage method, with LoadMessage method, you can edit subject, body text, from, recipient later. However, with this method, you can only specify the From and Recipients, EASendMail does not change the original email content, just uses new sender and recipient to forward the content to specified SMTP server.

Example

[VB6, VBA - Forward EML File]    
  Dim oSmtp As EASendMailObjLib.Mail
  Set oSmtp = New EASendMailObjLib.Mail

  'The license code for EASendMail ActiveX Object, 
  'for evaluation usage, please use "TryIt" as the license code.
  oSmtp.LicenseCode = "TryIt"
  
  oSmtp.ServerAddr = "mail.adminsystem.com"
  
  ' Set SMTP user authentication
  oSmtp.UserName = "test@adminsystem.com"
  oSmtp.Password = "test"
  
  'If your server requires SSL connection 
  'oSmtp.SSL_init 
  'oSmtp.SSL_starttls = 0 
  'oSmtp.ServerPort = 465
  
  'If your server requires TLS connection 
  'oSmtp.SSL_init 
  'oSmtp.SSL_starttls = 1 
  'oSmtp.ServerPort = 25

  ' load this email from file.
  oSmtp.LoadRawMessage "c:\my folder\test.eml", 1

  ' send the email with 100% original format.
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If

  oSmtp.raw_Content = ""

See Also

raw_Content Property
LoadMessage Method
ImportMailEx Method