SDK Gurus,
I am trying to figure it out whether it is possible to embed an html file in the outlook email body instead of an attachment (BO 6.5). I got the VBA code to attach the images such as .GIF files, but not for html or pdf files.
Could someone modify the code to embed the html file? Or if you have done this already, could you make some suggestions?
Here is the code:
Sub HTMLEmbed()
Dim objApp As Outlook.Application
Dim l_Msg As MailItem
Dim colAttach As Outlook.Attachments
Dim l_Attach As Outlook.Attachment
Dim oSession As MAPI.Session
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment
Dim colFields As MAPI.Fields
Dim oField As MAPI.Field
Dim strEntryID As String
’ create new Outlook MailItem
Set objApp = CreateObject(“Outlook.Application”)
Set l_Msg = objApp.CreateItem(olMailItem)
Set colAttach = l_Msg.Attachments
Set l_Attach = colAttach.Add(“C:\test.gif”)
l_Msg.Close olSave
strEntryID = l_Msg.EntryID
Set l_Msg = Nothing
Set colAttach = Nothing
Set l_Attach = Nothing
On Error Resume Next
Set oSession = CreateObject(“MAPI.Session”)
oSession.Logon “”, “”, False, False
Set oMsg = oSession.GetMessage(strEntryID)
Set oAttachs = oMsg.Attachments
Set oAttach = oAttachs.Item(1)
Set colFields = oAttach.Fields
Set oField = colFields.Add(CdoPR_ATTACH_MIME_TAG, “html”)
Set oField = colFields.Add(&H3712001E, “myident”)
oMsg.Fields.Add “{0820060000000000C000000000000046}0x8514”, 11, True
oMsg.Update
’ get the Outlook MailItem again
Set l_Msg = objApp.GetNamespace(“MAPI”).GetItemFromID(strEntryID)
’ add HTML content – the tag
l_Msg.HTMLBody = “”
l_Msg.Close (olSave)
l_Msg.Display
Set oField = Nothing
Set colFields = Nothing
Set oMsg = Nothing
oSession.Logoff
Set oSession = Nothing
Set objApp = Nothing
Set l_Msg = Nothing
End Sub
Thanks
Ravi.
Ravi_Pazhani (BOB member since 2002-08-20)