e-mail HTML messages

J

jamesdeckert

When I send an HTML e-mail, I must display the message, for the body to be
placed in the email. If I comment out the .display, the body of the email is
blank. I'd prefer not to display the message.

below is my code.

Dim objOutlook As Outlook.Application
Dim objMsg As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objMsg = objOutlook.CreateItem(olMailItem)
strBody = Replace(strBody, vbCrLf, "<br>")
With objMsg
.To = strRecipient
.Subject = strSubject
.BodyFormat = olFormatHTML
.HTMLBody = strBody
.Display ' body only appears if I Display first. Don't know why.
.Send
End With

Set objOutlook = Nothing
Set objMsg = Nothing

The ".BodyFormat = olFormatHTML" doesn't seem to make a difference whether
it is there or not.

Any ideas?
James
 
C

Cyberwolf

Did you know there is a way to send an email from Access without having to go
through all of that. It is the sendobject method of Docmd. The syntax can
be found in the help files but looks like this

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc]
[,subject][, messagetext][, editmessage][, templatefile]

The output format allows the use of HTML formats.

Just a suggestion.
 
J

jamesdeckert

James,
Yes I'm aware of sendobject. I however have never been able to get it to
send HTML. In fact, I couldn't get Outlook to send HTML until I put the
..display in.

here's the code I use
DoCmd.SendObject acSendNoObject, , acFormatHTML, strRecipient, , ,
strSubject, strBody, False

but it doesn't convert HTML tags to the appropriate format.

Any thoughts?
James

Cyberwolf said:
Did you know there is a way to send an email from Access without having to go
through all of that. It is the sendobject method of Docmd. The syntax can
be found in the help files but looks like this

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc]
[,subject][, messagetext][, editmessage][, templatefile]

The output format allows the use of HTML formats.

Just a suggestion.
--
James Gaylord
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


jamesdeckert said:
When I send an HTML e-mail, I must display the message, for the body to be
placed in the email. If I comment out the .display, the body of the email is
blank. I'd prefer not to display the message.

below is my code.

Dim objOutlook As Outlook.Application
Dim objMsg As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objMsg = objOutlook.CreateItem(olMailItem)
strBody = Replace(strBody, vbCrLf, "<br>")
With objMsg
.To = strRecipient
.Subject = strSubject
.BodyFormat = olFormatHTML
.HTMLBody = strBody
.Display ' body only appears if I Display first. Don't know why.
.Send
End With

Set objOutlook = Nothing
Set objMsg = Nothing

The ".BodyFormat = olFormatHTML" doesn't seem to make a difference whether
it is there or not.

Any ideas?
James
 
C

Cyberwolf

In that case I am unable to help.
--
James Gaylord
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


jamesdeckert said:
James,
Yes I'm aware of sendobject. I however have never been able to get it to
send HTML. In fact, I couldn't get Outlook to send HTML until I put the
.display in.

here's the code I use
DoCmd.SendObject acSendNoObject, , acFormatHTML, strRecipient, , ,
strSubject, strBody, False

but it doesn't convert HTML tags to the appropriate format.

Any thoughts?
James

Cyberwolf said:
Did you know there is a way to send an email from Access without having to go
through all of that. It is the sendobject method of Docmd. The syntax can
be found in the help files but looks like this

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc]
[,subject][, messagetext][, editmessage][, templatefile]

The output format allows the use of HTML formats.

Just a suggestion.
--
James Gaylord
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


jamesdeckert said:
When I send an HTML e-mail, I must display the message, for the body to be
placed in the email. If I comment out the .display, the body of the email is
blank. I'd prefer not to display the message.

below is my code.

Dim objOutlook As Outlook.Application
Dim objMsg As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objMsg = objOutlook.CreateItem(olMailItem)
strBody = Replace(strBody, vbCrLf, "<br>")
With objMsg
.To = strRecipient
.Subject = strSubject
.BodyFormat = olFormatHTML
.HTMLBody = strBody
.Display ' body only appears if I Display first. Don't know why.
.Send
End With

Set objOutlook = Nothing
Set objMsg = Nothing

The ".BodyFormat = olFormatHTML" doesn't seem to make a difference whether
it is there or not.

Any ideas?
James
 

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