Add an embedded attachment file to current email.
[Syntax] Visual C++: HRESULT AddInline( BSTR strFile, BSTR* pVal ) Visual Basic: AddInline( strFile As String ) As String
strFile
File or URL to be added.
Return Values
If this method succeeds, the return value is the Content-ID generated automatically by this method; otherwise the return value is null.
In some cases, the e-mail body includes a hyper-link which refers to a picture. In order to embed the picture in current email, you can use AddInline/AddInlineEx method. First developer can use AddInline/AddInlineEx method to add a picture to an e-mail, then change the hyper-link so that it points to <img src="cid:Content-ID">. This Content-ID is returned by this method.
ImportMailEx method provides a way to import html with embedded pictures to email easily.
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.BodyFormat = 1 'html email body
oSmtp.Subject = "Test"
Dim cid As String
'Add embedded picture and return the unique identifier of the attachment
cid = oSmtp.AddInline( "c:\test.gif" )
If cid = "" Then
MsgBox "add embedded picture failed"
MsgBox oSmtp.GetLastErrDescription()
Exit Sub
End If
'use the cid as link in the body text
oSmtp.BodyText = "<html><body>Hello, this is a embedded <img src=""cid:" & cid & """ > picture."
If oSmtp.SendMail() = 0 Then
MsgBox "Message delivered!"
Else
MsgBox oSmtp.GetLastErrDescription()
End If
End Sub
Online Examples
Visual C++ - Send HTML Email with Embedded Images
Visual Basic - Send HTML Email with Embedded Images
Delphi - Send HTML Email with Embedded Images
See Also