HTML OR PDF IN THE OUTLOOK EMAIL BODY

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)

Ok… Is it possible to save the rep or pdf or html or excel or rtf file as an image file such as .gif or bmp…etc? Please share your inputs.

Thanks
Ravi.


Ravi_Pazhani (BOB member since 2002-08-20)

Hi
we successfully use Chillkat MHT - a 3rd party tool - in our report refresh and distribution product for 5.x, 6.x and XI - ReportMessenger where we offer your requested feature.

Greetings


mhaberland :es: (BOB member since 2002-08-15)

I have problems too in using my excel.
Please give us tips.
Thanks


rein08 (BOB member since 2010-07-11)

Im using word as my email editor - took me a few searches but found a solution


Sub Email()
On Error Resume Next
Kill "c:\" & myFilename & ".pdf" 'Remove last instance of file
ThisDocument.ExportAsPDF "c:\" & myFilename & ".pdf" 'Save as PDF
'Create Email
        Set myolapp = CreateObject("Outlook.Application")
        Set mymail = myolapp.CreateItem(olmailitem)
        mymail.Subject = "Subject in here"
        mymail.to = "email in here" ' Team Leader Email
        mymail.Attachments.Add ("C:\" & myFilename & ".pdf"), olole 'Attach PDF File
        mymail.display
        'Embed PDF
        wordapp.Visible = True
        Set wordapp = GetObject(, "Word.Application")
        wordapp.selection.InlineShapes.AddOLEObject ClassType:="AcroExch.Document.7", _
        Filename:="c:\" & myFilename & ".pdf", LinkToFile:=False, _
        DisplayAsIcon:=False
End Sub

Titiro (BOB member since 2010-08-16)