automating e-mailfrom vb6 KEEP the HTML format

  • Thread starter Thread starter ton
  • Start date Start date
T

ton

hi,
it is not difficult to send an email in VB using the outlook model.
Especially when you just sent plain text
However what I want is the following:

I'want to use the VB to add or insert some text in the template default
style of the newmailitem.
This is how my code looks like:

Err.Clear
Set TheApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set TheApp = CreateObject("Outlook.Application")
Quit = True
End If
Err.Clear
On Error Resume Next
With TheApp
Set TheNameSpace = .GetNamespace("mapi")
If OFTfile<>"" Then
Set TheMailItem = .CreateItemFromTemplate(OFTfile)
Else
Set TheMailItem = .CreateItem(olMailItem)
End If
TheMailItem.Display 'WHEN DISPLAYING HERE THE TEMPALTE IS LOADED
End With
With TheMailItem
.Recipients.Add Adres
.Subject = Subject
If Body <> "" Then
.Body = Body '.HTMLbody=Body AFTER THIS LINE WE GOT A PROBLEM
End If
End With
'the problem is that the backgroud is white, and the tamplate was a
beautifull watermark picture in it.
So how can I keep the formatting
Just tell me with wich outlook version I can achieve this result
And how can I get it !!

Thank YOU all

ton
 
Am Wed, 30 Aug 2006 21:44:15 +0200 schrieb ton:

I think you need to add your text to the HTMLBody property.
 
I'tried this also, without any result.
Michael Bauer said:
Am Wed, 30 Aug 2006 21:44:15 +0200 schrieb ton:

I think you need to add your text to the HTMLBody property.
 
Am Thu, 31 Aug 2006 09:30:02 +0200 schrieb ton:

This sample works great.

Dim File As String
Dim Mail As Outlook.MailItem

File = "c:\template.oft"
Set Mail = Application.CreateItemFromTemplate(File)
Mail.Display
Mail.HTMLBody = Mail.HTMLBody & "hallo user"
Mail.Save
 
Back
Top