Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] simon_forer@optusnet.com.au is offline
external usenet poster
 
Posts: 2
Default Mail Merge HTML Format Word 2002 XP SP3

Hi have slightly modified Doug Robbin's code to merge 160 emails all
with attachments (some client specific, some generic). Thanks for code
Doug!!

From reading other posts in here, I gather the emails I send out (using

Word 2002 XP SP3) should retain formatting...but they don't.

Is there any extra code to send as HTML or is this just the default?

Code I'm using is:

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 String, message As String, title As String

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

' Show an input box asking the user for the subject to be inserted into
the email messages
message = "Enter the subject to be used for each email message." '
Set prompt.
title = " Email Subject Input" ' Set title.

' Display message, title
mysubject = InputBox(message, title)

' 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.Copy
Documents.Add
Selection.Paste

' Add Name to first line

Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=1,
Name:=""
Selection.TypeText Text:=Maillist.Tables(1).Cell(Counter, 1).Range
Selection.TypeParagraph
Selection.TypeParagraph


Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.Subject = mysubject
.Body = ActiveDocument.Content
Set Datarange = Maillist.Tables(1).Cell(Counter, 2).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
.Send HTML
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


Thanks
Simon

 
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
How to put graphics on envelopes? Steve Koenig Microsoft Word Help 21 April 29th 23 02:47 AM
Why can't I get Multiple instances of word? Laverne Microsoft Word Help 14 November 17th 06 01:35 PM
WP merge file to Word sstires Tables 4 February 14th 06 06:26 PM
Automate a mail merge in Word 2002 from a macro in Access 2002 Ed B Mailmerge 9 July 8th 05 04:31 PM
My hyperlinks dont work when I use HTML format in word mail merge Jens Ole Pedersen Mailmerge 2 March 1st 05 09:51 AM


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