PDA

View Full Version : Display mail before sending in mail merge



balamurali
09-25-2014, 11:15 AM
Hi,

Using word 2010 and outlook 2010, i have tried sending mail through mail merge.
My question is, Can we able to see the mail before sending?

That is after clicking finish and merge mail sends as per my data table in excel.
Its not even kept in my outbox? without reviewing or adding attachment my mail is sent through mail merge.

I need to attachment mail to my mail merge mail...

If my mail merge emails displayed or saved in outbox, i will open ans attach concern attachment to each and send?


How this can be achieved?

Please advise.

Thanks in advance...:banghead:

ranman256
09-25-2014, 01:06 PM
The SENDTONEWDOCUMENT shows the mail



Sub MergeIt()
'
' MergeIt Macro

'======================
'''YOU MUST ADD WORD OBJECT LIBRARY in VBE, tools, references
'======================
Dim wrd As Word.Application
Set wrd = CreateObject("Word.Application")
with wrd
.Visible = True
.Documents.Open("Y:\Reports\FESOP Certification.docx")
.ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\myfolder\db1.mdb (file://\\myfolder\db1.mdb)", ConfirmConversions:= _
False, ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:="QUERY qsMyQuery", SQLStatement:="SELECT * FROM [qsCheers]", _
SQLStatement1:="", SubType:=wdMergeSubTypeOther

With .ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub

gmayor
09-25-2014, 09:19 PM
May I suggest that you use http://www.gmayor.com/ManyToOne.htm In one to one mode it will create an individual message for each record, which can have a common or merged attachment. The messages are created in a temporary Outlook folder so that you can review them, before sending if you wish. The only proviso is that the data must be an Excel worksheet.

balamurali
09-26-2014, 06:38 AM
Hello gmayor, Thanks a lot for your addin suggestion... it looks greta, but i cannot use an add-in in my organisation because all addins are restricted. so i need a another way as ranman suggested..

hello ranman, Thanks a lot for your codes.. i need a clarification...

I cant understand this line [QUOTE]['''YOU MUST ADD WORD OBJECT LIBRARY in VBE, tools, references/QUOTE]
what it tells me to do...

and i can try your code as same as we do in excel right? by pasting in module of VBA editor in word, and editing the file paths and other codes accordingly?

I cant understand why thopse SQL lines are provided in the code, can you please explain....

sorry for too many questions? am totally new for VBA in word...

Thanks in advance.

gmayor
09-26-2014, 09:46 PM
The comment means that you must set a reference to the Word object library in the Outlook editor. You can use the code without doing that if you use late binding to the Word library instead of early binding (as shown). The equivalent would be:


Sub MergeIt()

Dim wrd As Object
Dim wrdDoc As Object
Set wrd = CreateObject("Word.Application")
With wrd
.Visible = True
Set wrdDoc = .Documents.Open("Y:\Reports\FESOP Certification.docx")
wrdDoc.MailMerge.OpenDataSource Name:= _
"\\myfolder\db1.mdb ("file://\\myfolder\db1.mdb")", ConfirmConversions:= _
False, ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="QUERY qsMyQuery", SQLStatement:="SELECT * FROM [qsCheers]", _
SQLStatement1:="", SubType:=0

With wrdDoc.MailMerge
.Destination = 0
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = -16
End With
.Execute Pause:=False
End With
End With
End Sub

However frankly I have no idea what this code has to do with your original problem. It appears to relate to conditions you haven't quoted, with reference to the merge document and its supposed data source, and all it will succeed in doing is to merge to a new document (if the SQL commands were to relate to your data). You don't need a macro to do that. You can simply merge to a new document from Word.

Creating code to merge with attachments is complex, and certainly no place for a VBA beginner to start. You are not going to achieve it with a few lines of code. The process used in my add-in, which you dismissed out of hand, due to some restrictive practices at work that prevent you from doing your job, does not use mail merge. It is a VBA process that works directly with the (Excel) data source.

I don't waste my time producing code for the benefit of Office users with malicious intent. I would suggest that you speak with management and get them to check out the add-in.