Reply
 
Thread Tools Display Modes
  #1   Report Post  
 
Posts: n/a
Default How to insert a field into the subject line as can be one in the word document?

A colleague has helped me to produce a mailmerge by linking a word 2003
document to a spreadsheet. Fields from a column in the spreadsheet can
be inserted into the document. However, I would ideally like to insert
a field into the subject line when the document is emailed to all the
recipients, otherwise a number of emails may be received that look like
duplicates. Any ideas how this can be done?

Incidentally, if an email address is typed in wrong into the
spreadsheet, I am forced into my outlook contacts area when the email
merge happens, can it be prevented from doing so to make sure I can not
risk sending the information to anyone in my outlook contacts?

Cheers
Colin

  #2   Report Post  
Doug Robbins - Word MVP
 
Posts: n/a
Default How to insert a field into the subject line as can be one in the word document?

This modification of the code in the article "Mail Merge to E-mail with
Attachments" at

http://word.mvps.org/FAQs/MailMerge/...ttachments.htm

picks up the subject for each email message from the second column of the
catalog mailmerge document that needs to be created for the mailmerge to
email with attachments to work. The field that contains the subjects must
of course be the second field in the catalog mailmerge main document.

Sub emailmergewithattachments()

Dim Source As Document, Maillist As Document
Dim Datarange As Range
Dim Counter As Integer, i As Integer
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim mysubject As Range

Set Source = ActiveDocument

' Check if Outlook is running. If it is not, start Outlook

On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

' Open the catalog mailmerge document

With Dialogs(wdDialogFileOpen)
.Show
End With
Set Maillist = ActiveDocument

' Iterate through the rows of the catalog mailmerge document, extracting the
information
' to be included in each email.
Counter = 1
While Counter = Maillist.Tables(1).Rows.Count
Source.Sections.First.Range.Cut
Documents.Add
Selection.Paste
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
Set mysubject = Maillist.Tables(1).Cell(Counter, 2).Range
mysubject.End = mysubject.End - 1
.Subject = mysubject
.Body = ActiveDocument.Content
Set Datarange = Maillist.Tables(1).Cell(Counter, 1).Range
Datarange.End = Datarange.End - 1
.To = Datarange
For i = 3 To Maillist.Tables(1).Columns.Count
Set Datarange = Maillist.Tables(1).Cell(Counter, i).Range
Datarange.End = Datarange.End - 1
.Attachments.Add Trim(Datarange.Text), olByValue, 1
Next i
.Importance = olImportanceHigh
.ReadReceiptRequested = True
.Send
End With
Set oItem = Nothing
ActiveDocument.Close wdDoNotSaveChanges
Counter = Counter + 1
Wend

' Close Outlook if it was started by this macro.

If bStarted Then
oOutlookApp.Quit
End If

'Clean up

Set oOutlookApp = Nothing
Source.Close wdDoNotSaveChanges
Maillist.Close wdDoNotSaveChanges

End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

wrote in message
oups.com...
A colleague has helped me to produce a mailmerge by linking a word 2003
document to a spreadsheet. Fields from a column in the spreadsheet can
be inserted into the document. However, I would ideally like to insert
a field into the subject line when the document is emailed to all the
recipients, otherwise a number of emails may be received that look like
duplicates. Any ideas how this can be done?

Incidentally, if an email address is typed in wrong into the
spreadsheet, I am forced into my outlook contacts area when the email
merge happens, can it be prevented from doing so to make sure I can not
risk sending the information to anyone in my outlook contacts?

Cheers
Colin



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
double window envelope tpdebronsky Page Layout 5 May 18th 23 08:51 PM
How do I create a Word form like corel WP merge documents? dlee_at_mmsgov Microsoft Word Help 2 October 8th 05 06:29 AM
How do I get rid of page numbers. The page number virus flamestar Microsoft Word Help 3 August 19th 05 02:31 AM
WordPerfect keyboard macro>Word equivalent? Anty New Users 2 March 13th 05 06:23 PM
Converted document from WordPerfect. New footnotes are not being. C Lowman Microsoft Word Help 1 January 26th 05 10:19 PM


All times are GMT +1. The time now is 04:07 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"