AddAttachmentEx Method

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

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


File or URL to be attached.
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.


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


[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 = ""
  ' set user authentication   
  oSmtp.UserName = ""
  oSmtp.Password = "test"
  oSmtp.FromAddr = ""
  oSmtp.AddRecipient "Support Team", "", 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!"
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub

See Also

AddAttachment Method
AddInline Method

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