soujanya bargavi
New Member
Members
Forum Posts: 1
Member Since:
July 13, 2018
July 13, 2018
Offline
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: 1586
Member Since:
October 5, 2010
October 5, 2010
Offline
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: Warren Murphy, Kathleen Silva, Brenda Wolf
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1917
SunnyKow: 1432
Anders Sehlstedt: 900
Purfleet: 414
Frans Visser: 346
David_Ng: 306
Hans Hallebeek: 290
lea cohen: 246
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
Cassandra McGuire
Leo Bonaparte
Excel Learner
david gavi
Rick KISA
Jan Elenbaas
Ranjeet Wankhade
Sugata Maity
Karen McCarron
Amanda Zibell
Forum Stats:
Groups: 3
Forums: 24
Topics: 6880
Posts: 30158
Member Stats:
Guest Posters: 49
Members: 33702
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —