automating e-mailfrom vb6 KEEP the HTML format

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
 
M

Michael Bauer [MVP - Outlook]

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

I think you need to add your text to the HTMLBody property.
 
T

ton

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.
 
M

Michael Bauer [MVP - Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top