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
strFile
File or URL to be attached.
strAlt
File name to be displayed in current email.
Return Values
If this method succeeds, the return value is zero; otherwise the return value is non-zero.
strFile must be a valid local file with full path or a valid URL.
Usage Example:
[Visual Basic]
Private Sub SendEmail()
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.net"
'If your server require user authentication
oSmtp.UserName = "test@adminsystem.net"
oSmtp.Password = "test"
oSmtp.FromAddr = "test@adminsystem.net"
oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0
oSmtp.BodyText = "Hello, this is a test...."
If oSmtp.AddAttachmentEx( "c:\test.doc", "mytest.doc") <> 0 Then
MsgBox "add attachment failed"
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