Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Heidi Heidi is offline
external usenet poster
 
Posts: 37
Default Email Mail Merge

Is there a way to enable voting buttons in outlook when doing an email mail
merge from Word?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Email Mail Merge

I don't think you can do this using the "out-of-the-box" email merge,
but you may be able to do it by using VBA to perform the merge. for
example, if you use the approach described by Doug Robbins at

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

then you should be able to set the voting options by, for example,
changing this bit of code

With oItem
.Subject = mysubject

to

With oItem
.Subject = mysubject
.VotingOptions = "option1;option2"

Unfortunately I can't verify this right now. There are also potentially
simpler but less well-tested macros for generating e-mails from Word,
e.g. for mail messages with a plain text body and an attachment you can
try the following Word VBA. Grham Mayor has some instructions for
installing and running VBA at

http://www.gmayor.com/installing_macro.htm



Sub EmailOneDocPerSourceRecWithBody()
Dim bOutlookStarted As Boolean
Dim bTerminateMerge As Boolean
Dim intSourceRecord As Integer
Dim objMailItem As Outlook.MailItem
Dim objMerge As Word.MailMerge
Dim objOutlook As Outlook.Application
Dim strMailCC As String
Dim strMailSubject As String
Dim strMailTo As String
Dim strMailBody As String
Dim strOutputDocumentName As String
Dim strVotingOptions As String
bOutlookStarted = False
bTerminateMerge = False
' Set up a reference to the
' Activedocument, partly because
' the ActiveDocument changes as you
' merge each record
Set objMerge = ActiveDocument.MailMerge
' Start Outlook as necessary
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
If Err 0 Then
Set objOutlook = CreateObject("Outlook.Application")
bOutlookStarted = True
End If
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"
intSourceRecord = 1
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
' while we are looking at the
' correct activerecord,
' create the mail subject, body, "to" and "cc"
' Just some sample code here - replace it with
' whatever you need. But ensure that the field names
' match the ones in your data source exactly - uppercase/lowercase
' differences are significant here
strMailSubject = _
"Results for " & _
objMerge.DataSource.DataFields("Firstname") & _
" " & objMerge.DataSource.DataFields("Lastname")
strMailBody = _
"Dear " & objMerge.DataSource.DataFields("Firstname") & _
vbCrLf & _
"Please find attached a Word document containing" & vbCrLf & _
"your results for..." & vbCrLf & _
vbCrLf & _
"Yours" & vbCrLf & _
"Your name"
strMailTo = objMerge.DataSource.DataFields("Emailaddress")
strMailCC = objMerge.DataSource.DataFields("CC")
strVotingOptions = "option1;option2"
' create the document path name
' In this case it can be the same for every recipient,
' but if you want to retain copies of the
' document, you can use info. in the data source
' this is an example - insert your
' own pathname here
strOutputDocumentName = "c:\a\results.doc"
' strOutputDocumentName = _
' "c:\mymergeletters\_" & _
' .DataSource.DataFields("Lastname").Value & _
' " letter.doc"
.DataSource.FirstRecord = intSourceRecord
.DataSource.LastRecord = intSourceRecord
.Destination = wdSendToNewDocument
.Execute
' The Activedocument is always the
' output document
' Add any parameters you need to these calls
ActiveDocument.SaveAs strOutputDocumentName
ActiveDocument.Close
' Now create a mail item
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
.Subject = strMailSubject
.Body = strMailBody
.To = strMailTo
.CC = strMailCC
.VotingOptions = strVotingOptions
.Attachments.Add strOutputDocumentName, olByValue, 1
'.Save
.Send
End With
Set objMailItem = Nothing
intSourceRecord = intSourceRecord + 1
End If
Loop
End With
' Close Outlook if appropriate
If bOutlookStarted Then
objOutlook.Quit
End If
Set objOutlook = Nothing
Set objMerge = Nothing
End Sub


However, if you need an HTML body, try starting with (the rather similar)
Sub EmailOneHTMLPagePerSourceRecWithBody()
' By Peter Jamieson, 2006
Dim bOutlookStarted As Boolean
Dim bTerminateMerge As Boolean
Dim intSourceRecord As Integer
Dim objMailItem As Outlook.MailItem
Dim objMerge As Word.MailMerge
Dim objOutlook As Outlook.Application
Dim strMailCC As String
Dim strMailSubject As String
Dim strMailTo As String
Dim strMailBody As String
Dim strOutputDocumentName As String
Dim strVotingOptions As String
bOutlookStarted = False
bTerminateMerge = False
' Set up a reference to the
' Activedocument, partly because
' the ActiveDocument changes as you
' merge each record
Set objMerge = ActiveDocument.MailMerge
' Start Outlook as necessary
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
If Err 0 Then
Set objOutlook = CreateObject("Outlook.Application")
bOutlookStarted = True
End If
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"
intSourceRecord = 1
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
' while we are looking at the
' correct activerecord,
' create the mail subject, body, "to" and "cc"
' Just some sample code here - replace it with
' whatever you need. But ensure that the field names
' match the ones in your data source exactly - uppercase/lowercase
' differences are significant here
strMailSubject = _
"Results for " & _
objMerge.DataSource.DataFields("Firstname") & _
" " & objMerge.DataSource.DataFields("Lastname")
' Use a simple sample
strMailBody = "HTMLBODYTABLE
BORDER=5TRTDk/TDTDt/TD/TR/TABLE/BODY/HTML"
strMailTo = objMerge.DataSource.DataFields("Emailaddress")
strMailCC = objMerge.DataSource.DataFields("CC")
strVotingOptions = "option1;option2"
' create the document path name
' In this case it can be the same for every recipient,
' but if you want to retain copies of the
' document, you can use info. in the data source
' this is an example - insert your
' own pathname here
strOutputDocumentName = "c:\a\results.htm"
' strOutputDocumentName = _
' "c:\mymergeletters\_" & _
' .DataSource.DataFields("Lastname").Value & _
' " letter.doc"
.DataSource.FirstRecord = intSourceRecord
.DataSource.LastRecord = intSourceRecord
.Destination = wdSendToNewDocument
.Execute
' The Activedocument is always the
' output document
' Add any parameters you need to these calls
ActiveDocument.SaveAs strOutputDocumentName, wdFormatFilteredHTML
ActiveDocument.Close
' Now create a new Mail Item
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
.BodyFormat = olFormatHTML
.Subject = strMailSubject
.HTMLBody = strMailBody
.To = strMailTo
.CC = strMailCC
.VotingOptions = strVotingOptions
.Attachments.Add strOutputDocumentName, olByValue, 1
.Save
.Send
End With
Set objMailItem = Nothing
intSourceRecord = intSourceRecord + 1
End If
Loop
End With
' Close Outlook if appropriate
If bOutlookStarted Then
objOutlook.Quit
End If
Set objOutlook = Nothing
Set objMerge = Nothing
End Sub




Peter Jamieson

http://tips.pjmsn.me.uk
See Ralph Watson's new Londinium video at http://www.ralphwatson.tv

Heidi wrote:
Is there a way to enable voting buttons in outlook when doing an email mail
merge from Word?

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Cathy Allington Cathy Allington is offline
external usenet poster
 
Posts: 9
Default Email Mail Merge

On Aug 28, 4:06*am, Heidi wrote:
Is there a way to enable voting buttons in outlook when doing an email mail
merge from Word?


Voting Options are only generally available to people on the same
Exchange network
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
Mail merge button Send email merge Gogol Farm Mailmerge 3 November 11th 08 07:29 PM
Merge to Printer works but Merge to E-mail doesn't email RIMikeG Mailmerge 4 September 6th 08 08:00 AM
e-mail merge errors w/ multiple email addresses in email field Jane Mailmerge 1 December 13th 07 05:43 PM
Word Mail-merge to email looses BG Color on Web-Based Mail Micmojav Mailmerge 4 September 18th 07 05:34 PM
email mail merge Diane Mailmerge 2 January 18th 06 08:25 AM


All times are GMT +1. The time now is 02:16 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"