AddInlineEx Method


Add an embedded image file to current email with customized file name

[Syntax]
Visual C++: HRESULT AddInlineEx(BSTR FileName, BSTR strAlt, BSTR* pVal) 
Visual Basic: AddInlineEx(FileName As String, strAlt As String) As String

Parameters

FileName
File or URL to be added.
strAlt
File name to be displayed in current email.

Return Value

If this method succeeds, the return value is Content-ID generated automatically by this method; otherwise the return value is null.

Remarks

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.
To attach embedded images or inline images, Mail.ImportHtml and Mail.ImportMailEx methods are strongly recommended.

Example

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

[VB6, VBA - Send Email with Embedded Images]

Const ConnectNormal = 0
Const ConnectSSLAuto = 1
Const ConnectSTARTTLS = 2
Const ConnectDirectSSL = 3
Const ConnectTryTLS = 4

Private Sub SendEmail()

    Dim oSmtp As EASendMailObjLib.Mail
    Set oSmtp = New EASendMailObjLib.Mail
    oSmtp.LicenseCode = "TryIt"

    ' Your SMTP server address
    oSmtp.ServerAddr = "smtp.emailarchitect.net"

    ' User and password for ESMTP authentication
    oSmtp.UserName = "test@emailarchitect.net"
    oSmtp.Password = "testpassword"

    ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically
    oSmtp.ConnectType = ConnectTryTLS
  
    oSmtp.FromAddr = "test@emailarchitect.net"
    oSmtp.AddRecipient "Support Team", "support@adminsystem.com", 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.AddInlineEx("c:\test.gif", "mytest.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  inline <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

ImportHtml
ImportMailEx
ClearInline Method
AddInline Method