T
Thomas Kroljic
All,
about a month ago I posted here and received some excellent help/advice. I
would now like to enhance my app even further. I have a form that allow the
user to send an email out to a specific recipient. I am using the vba code
that was on Tony Toews (MVP) website.
What I would like to do now is add a graphic image to this outgoing email.
Not as an attachment, but as part of the email body. What I recently did was
create a template in Outlook and saved this file to a specific subdirectory.
My vba logic is listed below. If I comment out the .HTMLbody part, then I
receive the email using the template which contains the image. If I attempt
to use the .HTMLbody part in, then the template becomes an attachment to the
email instead.
Is there a way to use the template but add additional text to the body of
the email?
Thank you,
Thomas kroljic
Dim AppOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim MailAttachment As Outlook.Attachment
Set AppOutLook = CreateObject("Outlook.Application")
Dim xref As Hyperlink
' logon
Dim xnamemail As String
xnamemail = "Default"
Call AppOutLook.GetNamespace("MAPI").Logon(Profile:=xnamemail)
'Set MailOutLook = AppOutLook.CreateItemFromTemplate
("D:\StoreManagement\EmailTemplates\NewTest01.oft")
Dim xhtmlstring As String
For X = 1 To Len(Me.txt_body) (i have an Access form that the user
enters text into)
If mID(Me.txt_body, X, 1) = Chr(13) Then
xhtmlstring = xhtmlstring + "<br />"
Else
xhtmlstring = xhtmlstring + mID(Me.txt_body, X, 1)
End If
Next X
With MailOutLook
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = Me.txt_to
.Subject = Me.txt_subject
If Me.txt_attachment <> "" And _
Not IsNull(Me.txt_attachment) Then
.Attachments.Add "d:\storemanagement\emailpdf\" & _
pEmailAttachment
End If
.HTMLBody = "<body>" & xhtmlstring & "<br />" & _
"<br />" & _
"<br />" & _
"<br />" & _
mEmpFullName & "<br />" & _
"<b>Jacobs Music Company<b/> " & "<br />" & _
"Phone Number: " & mPhoneNumber & "<br />" & _
IIf(mFaxNumber <> "", "Fax Number: " & mFaxNumber &
"<br />", "") & _
"Visit us at <a
href=http://www.jacobsmusic.com>www.jacobsmusic.com</a> " & "<br />" & _
"</body>"
'.Display True
.Send
End With
about a month ago I posted here and received some excellent help/advice. I
would now like to enhance my app even further. I have a form that allow the
user to send an email out to a specific recipient. I am using the vba code
that was on Tony Toews (MVP) website.
What I would like to do now is add a graphic image to this outgoing email.
Not as an attachment, but as part of the email body. What I recently did was
create a template in Outlook and saved this file to a specific subdirectory.
My vba logic is listed below. If I comment out the .HTMLbody part, then I
receive the email using the template which contains the image. If I attempt
to use the .HTMLbody part in, then the template becomes an attachment to the
email instead.
Is there a way to use the template but add additional text to the body of
the email?
Thank you,
Thomas kroljic
Dim AppOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim MailAttachment As Outlook.Attachment
Set AppOutLook = CreateObject("Outlook.Application")
Dim xref As Hyperlink
' logon
Dim xnamemail As String
xnamemail = "Default"
Call AppOutLook.GetNamespace("MAPI").Logon(Profile:=xnamemail)
'Set MailOutLook = AppOutLook.CreateItemFromTemplate
("D:\StoreManagement\EmailTemplates\NewTest01.oft")
Dim xhtmlstring As String
For X = 1 To Len(Me.txt_body) (i have an Access form that the user
enters text into)
If mID(Me.txt_body, X, 1) = Chr(13) Then
xhtmlstring = xhtmlstring + "<br />"
Else
xhtmlstring = xhtmlstring + mID(Me.txt_body, X, 1)
End If
Next X
With MailOutLook
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = Me.txt_to
.Subject = Me.txt_subject
If Me.txt_attachment <> "" And _
Not IsNull(Me.txt_attachment) Then
.Attachments.Add "d:\storemanagement\emailpdf\" & _
pEmailAttachment
End If
.HTMLBody = "<body>" & xhtmlstring & "<br />" & _
"<br />" & _
"<br />" & _
"<br />" & _
mEmpFullName & "<br />" & _
"<b>Jacobs Music Company<b/> " & "<br />" & _
"Phone Number: " & mPhoneNumber & "<br />" & _
IIf(mFaxNumber <> "", "Fax Number: " & mFaxNumber &
"<br />", "") & _
"Visit us at <a
href=http://www.jacobsmusic.com>www.jacobsmusic.com</a> " & "<br />" & _
"</body>"
'.Display True
.Send
End With