Hi All
I found this bit of code that appears to exactly what I need, but I can't get this one bit to work for me. It should be replacing "<< clientname >>" with the value in range A15, but it's not doing it?
Can anyone see a reason as to why it would not be working for me?
Many thanks for your help in advance!
I found this bit of code that appears to exactly what I need, but I can't get this one bit to work for me. It should be replacing "<< clientname >>" with the value in range A15, but it's not doing it?
Can anyone see a reason as to why it would not be working for me?
Many thanks for your help in advance!
Code:
[FONT=Verdana]Sub testing()[/FONT]
[FONT=Verdana]Dim myOlApp As Outlook.Application[/FONT]
[FONT=Verdana]Dim MyItem As Outlook.MailItem[/FONT]
[FONT=Verdana]Set myOlApp = CreateObject("Outlook.Application")[/FONT]
[FONT=Verdana]Set MyItem = myOlApp.CreateItemFromTemplate("\\DATA1\myname$\Desktop\Projects\M\mytemplate.oft")[/FONT]
[FONT=Verdana]With MyItem[/FONT]
[FONT=Verdana] .To = Worksheets("lookup").Range("A14")[/FONT]
[FONT=Verdana] .Subject = "Monthly bill"[/FONT]
[FONT=Verdana] 'Refer to and fill in variable items in template[/FONT]
[FONT=Verdana] .HTMLBody = Replace(.HTMLBody, "<< Clientname >>", Sheets("Lookup").Range("A15"))[/FONT]
[FONT=Verdana] .Display[/FONT]
[FONT=Verdana]End With[/FONT]
[FONT=Verdana]Set MyItem = Nothing[/FONT]
[FONT=Verdana]Set myOlApp = Nothing[/FONT]
[FONT=Verdana]End Sub[/FONT]
Last edited: