• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need help with OutlookVBA for finding and replacing the text from original email

Ratish

New Member
Hi,

Not sure if I am posting below query to correct audience.

I am trying to run outlook VBA to find and replace text from original email to new email to bunch of stakeholders. Finding difficulty to run the script.
Scenario, I get an email which has Company Name list. So whenever I am running this script it should replace with company name listed on the original email. Below is my script.

Sub Test()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Dim oRespond As Outlook.MailItem
Dim strcompany As String
Dim strHTML As String

Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate("C:\Users\test-.oft")
strcompany = InputBox("Issue : ", "Replace %company%")
strHTML = Replace(replyEmail.HTMLBody, "Company:", strissue)
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Subject = replyEmail.Subject & origEmail.Reply.Subject


replyEmail.Display

End Sub
 
Back
Top