
Signature
Sylvie Quesnel
Analyste de systèmes / IT Systems Analyst
La Cité collégiale
801, prom. de l''''Aviation
Ottawa (Ontario) K1K 4R3
squesn@lacitec.on.ca
(613)742-2493 poste 2869 Fax: (613)742-2488
Does it always fail with the same e-mail addresses, or does it appear to be
random? e.g., if you make two data files:
a. one with the records that go wrong
b. one with the records that go right
when you merge to (a), do they all still go wrong? And when you merge to
(b), do they all go right?
If that is the case, then I would have to guess that something is probably
trying to "verify" the addresses in some way (e.g. Outlook does this if I
enter my address as "Peter Jamieson" rather than pjj@whatever.
But since I do not know what is going wrong, I can only suggest that you try
the following workaround, which performs one mail merge for each record in
the data source. (Of course, if the problem is something to do with the way
that each e-mail address is processed, this will probably still fail).
e.g.
Sub ProduceOneEmailPerSourceRec()
'
' NB, needs bettor error management and doubtless other things a VBA expert
' will point out.
Dim intSourceRecord
Dim objMerge As Word.MailMerge
Dim bTerminateMerge As Boolean
' Need to set up this object as the ActiveDocument changes when the
' merge is performed. Besides, it's clearer.
Set objMerge = ActiveDocument.MailMerge
With objMerge
' If no data source has been defined, do it here using OpenDataSource.
' But if it is already defined in the document, you should not need to
define it here.
' .OpenDataSource _
' Name:="whatever"
' I don't use FirstRecord, LastRecord because they do not behave
' the way you expect in all data sources.
intSourceRecord = 1
bTerminateMerge = False
Do Until bTerminateMerge
.DataSource.ActiveRecord = intSourceRecord
' if we have gone past the end (and possibly, if there are no records)
' then the Activerecord will not be what we have just tried to set it to
If .DataSource.ActiveRecord <> intSourceRecord Then
bTerminateMerge = True
' the record exists
Else
.DataSource.FirstRecord = intSourceRecord
.DataSource.LastRecord = intSourceRecord
.Destination = = wdSendToEmail
' set up the field containing the e-mail address - use your own field
name
.MailAddressFieldName = "eaddress"
' Set up the subject - make sure any field name in here has the same
' capitalisaiton as the name in the data source
.MailSubject = .DataSource.DataFields("FirstName").Value & _
"- here's your data for 2007"
.Execute
intSourceRecord = intSourceRecord + 1
End If
Loop
End With

Signature
Peter Jamieson
http://tips.pjmsn.me.uk
> Yes, all the rows in my test .csv file have a valid e-mail address in the
> column I select as the "email address field" (EmailID). None of them are
[quoted text clipped - 54 lines]
>> >
>> > Thank you
Sylvie - 31 Jan 2008 16:42 GMT
It swaps e-mail addresses randomly. I just did 3 tests and I got different
swaps each time. So I wouldn't even know how to split the file...
I'm not sure I follow you with the workaround you suggested. I'm not sure
if or how you want me to use the ProduceOneEmailPerSourceRec() procedure.
Can you help me out on this one? Thank you
> Does it always fail with the same e-mail addresses, or does it appear to be
> random? e.g., if you make two data files:
[quoted text clipped - 126 lines]
> >> >
> >> > Thank you
Peter Jamieson - 31 Jan 2008 16:56 GMT
> I'm not sure I follow you with the workaround you suggested. I'm not sure
> if or how you want me to use the ProduceOneEmailPerSourceRec() procedure.
The idea of the workaround is that you
a. put the VBA code where it can be run (see, e.g.
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
b. create your mail merge main document and connect it to your data source
in the usual way
c. instead of clicking on any of the usual options to start your merge to
email, run the macro
All the macro does is perform one merge for each record in the data source.
It is possible that by doing that, you will avoid the problem. However,
since we do not know the cause of this problem and the substitution appears
to be random, this approach may not work either.

Signature
Peter Jamieson
http://tips.pjmsn.me.uk
> It swaps e-mail addresses randomly. I just did 3 tests and I got
> different
[quoted text clipped - 155 lines]
>> >> >
>> >> > Thank you