I am trying to create an email from an oft templaye and replace certain part using the replace() function. I can get the email to open up but not of the replaces are working.
Can anyone off any help?
Can anyone off any help?
Code:
[FONT="]Dim myOlApp As Outlook.Application[/FONT]
[FONT="]Dim MyItem As Outlook.MailItem[/FONT]
[FONT="]Dim objDoc As Object[/FONT]
[FONT="]Dim OutlookRecip As String[/FONT]
[FONT="]Dim strCustomer As String[/FONT]
[FONT="]Dim strHTML As String[/FONT]
[FONT="] [/FONT]
[FONT="] [/FONT]
[FONT="]Set myOlApp = CreateObject("Outlook.Application")[/FONT]
[FONT="]Set MyItem =[/FONT]
[FONT="]myOlApp.CreateItemFromTemplate("C:\template.oft")[/FONT]
[FONT="]strCustomer = "Simon"[/FONT]
[FONT="]strHTML = Replace(MyItem.HTMLBody,"%subfirstname%", strCustomer)[/FONT]
[FONT="]MyItem.Display[/FONT]
[FONT="]Set objDoc = MyItem.GetInspector.WordEditor[/FONT]
[FONT="]objDoc.Windows(1).Selection.Find.ClearFormatting[/FONT]
[FONT="]objDoc.Windows(1).Selection.Find.Execute strSender[/FONT]
[FONT="]Set myOlApp = Nothing[/FONT]
[FONT="]Set MyItem = Nothing[/FONT]
[FONT="]Set objDoc = Nothing[/FONT]