
soujanya bargavi
New Member
Members

Forum Posts: 1
Member Since:
July 13, 2018
July 13, 2018

Can you help me with why this doesn't work? As of right now, this code will open up an email template that I created but I would like it to find the %recipient% on the opened email and replace it from the excel sheet with the recipient name in range B2.
I have just pieced code that I have found online together to make it this far but could use some help as to why excel doesn't recognize and change the%recipient% on the outlook message template I created. The attempt is to make it like the mail merge function that is used between excel and word but with excel and an outlook email template.
Sheets("Email Addresses").Range("A2").Select Do Until IsEmpty(ActiveCell.Value) ActiveCell.Offset(1, 0).Select 'Looping Dim OutApp As Object Dim OutMail As Object Dim count As Integer EmailTo = Worksheets("Email Addresses").Range("A2") Recipient = Worksheets("Email Addresses").Range("B2") Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItemFromTemplate( _ Sheets("Start Here").Range("B25")) On Error Resume Next ' Change the mail address and subject in the macro before you run it. With OutMail .To = EmailTo .Body = Replace(.Body, "%recipient%", Recipient) .Display

Philip Treacy
Admin

Forum Posts: 1550
Member Since:
October 5, 2010
October 5, 2010

Hi,
Without your files to look at it's hard to work out what you code is doing.
If you want to change the email address you are sending the email to you can use
.To = Range("B2").Value
Please refer to this post which may be able to help you
https://www.myonlinetraininghu.....th-outlook
Regards
Phil
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Philip Treacy, Peter Venkatrao, QSolutions Group
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 185
Newest Members:
Kate Dyka
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6546
Posts: 28655
Member Stats:
Guest Posters: 49
Members: 32832
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —
