Hello
I have been using the CDONTS.Newmail object for a number of years to send
nicely formatted HTML Emails with inline images.
I am now trying to switch over to using CDO and I cannot reproduce this
functionality. I am using the AddAttachment method instead of the old
AttachURL method but the attached images just show as separately attached
files rather than in line in the HTML.
According to MSDN:
"If you populate the HTMLBody property before calling the AddAttachment
method, any inline images are displayed as part of the message."
Well, I am doing that but it is not working. The images show up as if I had
attached them using the old AttachFile method.
Code follows.
Any help would be appreciated.
David
If bHasResults Then
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = cdoSendUsingPort
.Item(sch & "smtpserver") = "192.168.0.1"
.Update
End With
For j = 0 To iResults
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = arrResults(1, j)
.To = arrResults(2, j)
.Subject = arrResults(3, j)
If arrResults(5, j) Then ' The email has an HTML Body and may have inline
attachments
.MIMEFormatted = True
.HTMLBody = arrResults(4, j)
.AutoGenerateTextBody = True
If Not IsNull(arrResults(6, j)) Then ' It does have inline attachments
arrAttachURL = Split(arrResults(6, j), ",")
For i = 0 To UBound(arrAttachURL) Step 2
.AddAttachment arrAttachURL(i) ', arrAttachURL(i +1)
Next
End If
Else ' It's a text email
.MIMEFormatted = False
.TextBody = arrResults(4, j)
End If
.Send
objConn.Execute "DELETE FROM dbo.tblOutboundEmailQueue WHERE (EmailID = "
& arrResults(0, j) & ")", , adCmdText + adExecuteNoRecords
End With
Set cdoMessage = Nothing
Next
End If