Attach a file or URL as attachment to current email.
[Syntax] Visual C++: HRESULT AddAttachment( BSTR strFile, long* pVal ) Visual Basic: AddAttachment( strFile As String ) As Long
strFile
File or URL to be attached.
Return Values
Return zero if successful, or return non-zero if failed.
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.AddAttachment( "c:\test.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