Sending embeded image using STMP

mafhobb

Registered User.
Local time
Today, 05:38
Joined
Feb 28, 2006
Messages
1,249
I have STMP code that I use to send e-mail messages from a database.
Code:
Dim iMsg
Dim iConf
Const cdoSendUsingPort = 2
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

With Flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xx.xx.x.xx"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
    .Update
End With

' Apply the settings to the message.
With iMsg
    Set .Configuration = iConf
    .to = txtRecipient
    .from = txtSender
    .Bcc = txtBlack
    .Subject = txtsubject
    .HTMLBody = txtBody

DoEvents

    .Send
End With

Does anyone know if it is possible to send embeded images using SMTP VBA code?

Thanks

mafhobb
 
Is it possible to embed images in an SMTP e-mail?
 
Yes, you can send embedded images provided your txtBody is legitimate HTML coding including the image.

An example
Code:
 strMsg = "<!DOCTYPE HTML PUBLIC " & Chr(34) & "-//W3C//DTD HTML 3.2 Final//EN" & Chr(34) & ">" & vbCrLf & _
      "<HTML>" & vbCrLf & _
      "<BODY>" & vbCrLf & _
      "<style type='text/css'>" & _
      "p.tab { margin-left: 20px;} p.small {line-height:30%;} p.Indentsmall {margin-left: 20px; line-height:80%;}" & _
      "</style>" & _
      "<P font face='verdana'>Hi " & Left(Me.txtRecdFrom, n - 1) & ",</P>" & vbCrLf & _
      "<p></P><p></P>" & _
      "<P>Please find attached the following in relation to your booking at XXXX Lodge</P>" & _
      "<UL>" & strAttachments & "</UL>" & _
      "<p></P><p></P>" & _
      "<p>We look forward to seeing you on " & Format(Forms!frmBooking!txtDateIn, "mmmm") & ".</p>" & _
      "<p>Warm Regards</p>" & _
      "<p>XXXX</p><p></P>" & _
      "<IMG SRC='C:\Lodge\Templates\image001.jpg'/>" & _
      "</BODY>" & _
      "</HTML>"
 

Users who are viewing this thread

Back
Top Bottom