Using a Word doc as an email template

Chi1linVi1lain

Registered User.
Local time
Yesterday, 19:22
Joined
Sep 22, 2011
Messages
11
What I'd like to do is use a Word 2007 (.docx) file as the body of the email message. (It has a company logo and a html link in the file) My code works perfectly if I type a string of text for the body, however, I'd like to dress up the email and have it send an email with the logo & link to the website and I'd prefer it do this via word template.


I just need a little help getting the contents of the word doc "copied" into the email message. Any help would be appreciated.
 
Private Sub Command86_Click()


QuotedID = Me.QuoteID

DoCmd.OpenQuery "QuoteStatusDeliveryUpdate"

Dim myPath As String
Dim strReportName As String

myPath = "J:\AccessApp\QuotesTemp\"
strReportName = "Finishing-TechnologySalesQuote" & ".pdf"

DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, False

'On Error GoTo Err_C1Email_DblClick
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim MailAttach As Variant
Dim EmailAddress As String
Dim Body As String

Set OutApp = CreateObject("Outlook.Application", "localhost")
Set OutMail = OutApp.CreateItem(olMailItem)
Set MailAttach = OutMail.Attachments
With OutMail

.SentOnBehalfOfName = "(Removed)"
.To = [Reports]![rptQuote]!
.CC = [Reports]![rptQuote]![RepEmail]
.BCC = ""
.Subject = "RE: Your " & [Reports]![rptQuote]![qryPrintQuoteService subreport]![Process] & " Quote"
.Body = "Test"
.Attachments.Add "J:\AccessApp\QuotesTemp\Finishing-TechnologySalesQuote.pdf", olByValue, 1
.Display
End With

Set OutMail = Nothing
Set OutApp = Nothing

MsgBox "Please note that Outlook must be running in order for this email to actually send.", vbQuestion + vbOKOnly, "Is Outlook Open?"


Exit_C1Email_DblClick:
Exit Sub

Err_C1Email_DblClick:
MsgBox Err.Description
Resume Exit_C1Email_DblClick

I just need a little help getting the contents of the word doc "copied" into the email message. Any help would be appreciated. Very sorry about the blank posts... but the forum requires 10 posts in order to allow email addresses.
 
I don't have enough posts to post code yet...
 
Here's the answer to the problem I was experiencing earlier:

I ended up setting the template via Outlook (.oft) instead of Word (.docx) easy enough from there...


QuotedID = Me.QuoteID

DoCmd.OpenQuery "QuoteStatusDeliveryUpdate"

Dim myPath As String
Dim strReportName As String

myPath = "J:\AccessApp\QuotesTemp\"
strReportName = "Finishing-TechnologySalesQuote" & ".pdf"

DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, False

'On Error GoTo Err_C1Email_DblClick
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim MailAttach As Variant
Dim EmailAddress As String
Dim BodyFile As String
Set OutApp = CreateObject("Outlook.Application", "localhost")
Set OutMail = OutApp.CreateItemFromTemplate("J:\AccessApp\QuotesTemp\QuoteTemplate.oft")
Set MailAttach = OutMail.Attachments
With OutMail

.SentOnBehalfOfName = "Email_address_removed"
.To = [Reports]![rptQuote]!
.CC = [Reports]![rptQuote]![RepEmail]
.BCC = ""
.Subject = "RE: Your " & [Reports]![rptQuote]![qryPrintQuoteService subreport]![Process] & " Quote from Finishing Technology Inc"
.Attachments.Add "J:\AccessApp\QuotesTemp\Finishing-TechnologySalesQuote.pdf", olByValue, 1
.Display 'or when your ready to really email use .Send

End With

Set OutMail = Nothing
Set OutApp = Nothing

MsgBox "Please note that Outlook must be running in order for this email to actually send.", vbQuestion + vbOKOnly, "Is Outlook Open?"


Exit_C1Email_DblClick:
Exit Sub

Err_C1Email_DblClick:
MsgBox Err.Description
Resume Exit_C1Email_DblClick
 

Users who are viewing this thread

Back
Top Bottom