VBA to email merge

jhahes

Registered User.
Local time
Yesterday, 16:42
Joined
Jul 13, 2005
Messages
20
Is there anyway to automate or a piece of code to email merge with a word document.

I am trying to send email updates to clients, most of the email is text with a couple of database fields in each document. I could code the html on the back side, the only problem is that I am unable to get in a header that has graphics. So the easiest way is to use an existing word document and email merge, but is there a way to do this through code.


thanks for any help

Josh
 
Hi Josh
This is not EXACTLY what you want, but it should get you started.
In this code, I am emailing a snapshot of a report.

Just one word of caution here - Each time that a mail is sent, you get a warning telling you that the system is trying to send mail (possibly) without your knowledge. This happens for EVERY mail. Unfortunately, I dont know how to turn this option off?



Private Sub Command15_Click()
On Error GoTo Err_Command15_Click
'***************************************
Dim MyRptName As String
Dim MyFormat As String
Dim MyTo As String
Dim MySubj As String
Dim MyMsg As String

'HTML (*.htm; *.html)
'Text Files (*.txt)
'Microsoft Active Server Pages (*.asp)
'Microsoft Excel (*.xls)
'Microsoft Excel 5-7 (*.xls)
'Microsoft Excel 97-10 (*.xls)
'Microsoft IIS (*.htx, *.idc)
'Rich Text Format (*.rtf)
'Data Access Page (*.htm; *.html)
'XML (*.xml)

MyRptName = "My_Invoice_" & Me.InvID
MyFormat = "SnapshotFormat(*.snp)"
MyTo = Me.Label16.Caption
MySubj = "My Invoice_" & Me.InvID
MyBody = "Please find a copy of the " & MySubj & " attached for your perusal." _
& vbCr & "If you have any queries regarding this invoice, please contact me accordingly" _
& vbCr & vbCr _
& vbCr & "Thanks & Regards" _
& vbCr & "Arnold Swartzenegger"

DoCmd.SendObject acReport, "RptSingleInvoice", MyFormat, MyTo, "", "", MySubj, MyBody, False, ""

Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom