sending HTML Email

  • Thread starter Thread starter Cory J. Laidlaw, Beyond01.com
  • Start date Start date
C

Cory J. Laidlaw, Beyond01.com

Howdy!

I need to be able to send HTML email with an embedded graphic attachment
from Access from code.

If anyone has any guidance, I would gladly appreciate it!

Thanks!
 
Hi Doug,

thanks for responding. Saldy, His article says it does not support HTML, but
rather just formats text using the VBA Format() function.

Cory
 
Cory,

I believe, although I have never tried it yet, that you can automate Outlook
in this manner. Instead of using the .body to input your body text, use
instead the .HTMLbody and code your content in HTML. Then you should be able
to input an image tag as you please. I think! Please post back if this
works, or not, so that I and others will know whether or not it worked.

You can get the base Outlook automation code a
http://msdn2.microsoft.com/en-us/li...odc_ac_olauto_sendanoutlookmessageusingaccess
and then modify it as I mentioned.
--
Hope this helps,

Daniel Pineault
For Access Tips and Examples: http://www.cardaconsultants.com/en/msaccess.php
If this post was helpful, please rate it by using the vote buttons.
 
I see nothing on that page that says it doesn't support HTML. It says the
SendObject method doesn't support HTML, but he shows ways around using
SendObject elsewhere on his page.

I would assume that the reason why
http://www.granite.ab.ca/access/email/formattedsamplecode.htm doesn't
include specific code to send the e-mail is because how you do it depends on
what method you're using to send e-mail.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Cory J. Laidlaw, Beyond01.com"
 
The following will work for other aspects of HTML email. However I
have NEVER tried an image situation.

I would suggest creating an email the way you want it to appear (with
an image) and then send it to yourself.
On a received HTML message if you then select
View
View in Internet Zone
then right click in the msg area and select View Source
you will then see something like this:
<DIV><FONT face=Arial size=2><SPAN class=307413020-05032008><IMG
alt="" hspace=0
src="cid:307413020@05032008-2445" align=baseline border=0></SPAN></
FONT></DIV>

I am not usre how you could programatically derive that.
However you can "Attach graphics like any other document to your
email.

Here is the code for normal stuff as promissed:

===========================================

Set o = CreateObject("Outlook.Application")
Set m = o.CreateItem(0)


m.To = Forms![HiddenKey]![HManagerEmail]
' m.cc = for copies

' m.bcc = for blind copies

m.Subject = "Defect Analysis for " & Forms![fieldname]

' m.body = "now is the time" if html not
desired

==================================
m.bodyformat = 2 ' not necessary if no html
' that is what
makes it HTML
' next line loads
HTMLBody..
m.htmlbody = Chr(13) & Chr(13) & _
"<body><Table><tr><td><b> Date: </b></td><td>" & Date
&
"</td></tr>" & _
"<tr><td><b>Manager: </b></td><td>" &
Forms![HiddenKey]![HManager] & "</td></tr>" & _
"<tr><td><b>Name: </b></td><td>" &
Forms![HiddenKey]![HCompany] & "</td></tr>" & _

"<tr><td></td><td></td></tr>" & _
"</Table></body>"
===================================

' m.send ' to send it instead of displaying it.
m.Display


==============================================

Watch for wrapping.......


Ron
 
Hi Guys,

Thanks for the pointer. I got it to work ! Thanks for all of your help!

I used this:

Private Sub Command0_Click()

' need reference for current version like
' Microsoft Outlook 11.0 Object Library

Dim app As Outlook.Application
Dim msg As Outlook.MailItem
Dim recip As Outlook.Recipient

Set app = CreateObject("outlook.application")
Set msg = app.CreateItem(olMailItem)
With msg
Set recip = .Recipients.Add("(e-mail address removed)")
.Subject = "HTML Email test"
.HTMLBody = "Normal <b>Bold</b> Normal. <img alt=''
src='http://beyond01/logo.jpg' width='786' height='150' />"
.GetInspector = 2
.Send
End With

End Sub
 
Back
Top