
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: 1514
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: Lynnette Altomari, Sherry Fox, Riny van Eekelen, Dieneba NDIAYE, Tucker Oakley
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Sopi Yuniarti
sandra parker
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Forum Stats:
Groups: 3
Forums: 24
Topics: 6214
Posts: 27243
Member Stats:
Guest Posters: 49
Members: 31894
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —
