AddInlineEx Method

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

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


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


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.


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

[VB6, VBA - Send Email with Embedded Images]

Private Sub SendEmail()
  Dim oSmtp As EASendMailObjLib.Mail
  Set oSmtp = New EASendMailObjLib.Mail

  oSmtp.LicenseCode = "TryIt"
  oSmtp.ServerAddr = ""
  ' Set SMTP user authentication 
  oSmtp.UserName = ""
  oSmtp.Password = "test"
  oSmtp.FromAddr = ""
  oSmtp.AddRecipient "Support Team", "", 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!"
    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

ClearInline Method
AddInline Method