AddAttachmentEx Method


Attach a file or URL as attachment to current email with customized file name.

[Syntax]
C++: HRESULT AddAttachmentEx( BSTR strFile, BSTR strAlt, long* pVal )
Visual Basic: AddAttachmentEx( strFile As String, strAlt As String ) As Long

Parameters

strFile
File or URL to be attached.
strAlt
File name to be displayed in current email.

Return Value

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

Remarks

strFile must be a valid local file with full path or a valid URL.

Example

[Visual Basic] To get the full samples of EASendMail, please refer to Samples section.

[VB6, VBA - Send Email with Attachment]
Private Sub SendEmail()
  Dim oSmtp As EASendMailObjLib.Mail
  Set oSmtp = New EASendMailObjLib.Mail

  oSmtp.LicenseCode = "TryIt"

  oSmtp.ServerAddr = "mail.emailarchitect.net"
  ' set user authentication   
  oSmtp.UserName = "test@emailarchitect.net"
  oSmtp.Password = "test"
  
  oSmtp.FromAddr = "test@emailarchitect.net"
  oSmtp.AddRecipient "Support Team", "support@emailarchitect.net", 0
  oSmtp.BodyText = "Hello, this is a test...."
  
  If oSmtp.AddAttachmentEx( "c:\test.doc", "mytest.doc") <> 0 Then
    MsgBox "failed to add attachment"
    MsgBox oSmtp.GetLastErrDescription()
    Exit Sub
  End If
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub

See Also

AddAttachment Method
AddInline Method
ImportHtml
ImportMailEx

Online Examples

VB6- Send Email with Attachment
VB6 - Send Email with Embedded Images
Delphi - Send Email with Attachment
Delphi - Send Email with Embedded Images
Visual C++ - Send Email with Attachment
Visual C++ - Send Email with Embedded Images