Mail Merge Email

C

Chip

Hey Everyone,

I'm not sure if this has been answered yet or not. Mr. Kallal's Super
Easy Mail Merge is working awesome for many of my applications. But I
was hoping someone could show me if there is an easy to augment this
code to send these mail merge documents, as attachments to an Outlook
email. I have some experience with Outlook coding in Access and I
have a rudementary application running. So I need to merge (sorry for
the pun) the two technologies; Mail Merge and Outlook.

Currently my Outlook code looks like this

On Error GoTo AddTask_Err
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
Dim outobj As Outlook.Application
Dim outmail As Outlook.MailItem
Set outobj = CreateObject("outlook.application")
Set outmail = outobj.CreateItem(olMailItem)
With outmail
.To = "(e-mail address removed)" ' This will be changed to a
predetermined field.
.Subject = "Certification Course Approval"
.BodyFormat = olFormatHTML
.Actions
.Save
.Send
End With
' Release the Outlook object variable.
Set outobj = Nothing
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Approval Sent!"
Exit Sub
AddTask_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub

And of course the super easy mail merge application code is
MergeSingleWord. I'm supposing that what I need is save the document
in MailMerge termporarily, then email the document as an attachment in
the Outlook Code. I know there is a .Attachment arguement but dont
know how to set its parameters.

This is going way beyond my expertise and I'm hoping someone can take
pity on me here... Any and all sugestions are appreciated..

Chip Franklin
 
A

Albert D. Kallal

The only problem here is does the user need to edit the word document and
THEN attach it?

Or, do you just need to choose an existing template, and merge + attached to
outlook?

If there is 2 or 3 templates that you know that you want to be send/attached
to outlook, then you can use the merge no prompts option.

eg:

MergeNoPrompts strFromDocTemplate, [strDir], [bolFullPath], [strOutPutDoc],
[strSql], [bolPrint], [strPrinter]

So, lets assume the template is "overdue". You could then go:

strDocName = "c:\mymerge.doc"

MergeNoPrompts "overdue",,false,"c:\myMerge.doc",,False

Set outmail = outobj.CreateItem(olMailItem)
With outmail
.To = "(e-mail address removed)" ' This will be changed to a
predetermined field.
.Subject = "Certification Course Approval"
.BodyFormat = olFormatHTML

.Attachments.Add (strDocName) <--- add this


The above is the general approach here.

So, add the code to save/create the merged document into a folder. And then
add the attachments.Add to the outlook code to attach that word document.

You could have 2 or 3 differnt buttons on the form to allow the user to
choose what email.
 
J

jessie

I would like to know how I can possibly sign onto the internet. I have just
purchased a laptop and unfortunately the so called administrator doesn't
remember the p word. help i have vista and I dont know anything about this
os
 

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