PDA

View Full Version : [SOLVED:] Outlook2013-create-HTML-Reply-email-and-remove-chaff



New1992
06-08-2016, 05:43 PM
I've written some code that uses a user form to get user information and creates a reply email (to the one highlighted in outlook). To do this I used the item.Reply function from the highlighted email. I then put the data from the user form into a new email with the Reply.HTML at the end. I am looking for a way to delete the TO, CC, BCC, and Subjects from the new email.

I have the code written such that those sections are taken from the hilighted email and converted to a string. When I try to remove that string from the new email it doesn't work. I think the code is reading the <email> as HTML formatting and removing it from the text. Does anyone have any ideas on how to avoid this?



Simply put: replace text in an HTML email draft that is similar to "John Smith <emaill>"

gmayor
06-08-2016, 09:16 PM
Do you mean like the following?

Dim olMsg As MailItem
Dim olReply As MailItem
Dim olRecipient As Recipient
Set olMsg = ActiveExplorer.Selection.Item(1)
Set olReply = olMsg.Reply
With olReply
For Each olRecipient In olReply.Recipients
olRecipient.Delete
Next olRecipient
.subject = ""
.Display
End With

New1992
06-09-2016, 05:37 AM
Not quite, I am trying to remove the blue lines in the example draft email message below.

Draft email body:

New email text here.

-----Original Message-----
From: me <email?
Sent: Thursday, June 09, 2016 7:31
To: Joe Dirt <email>
Subject: Hello!

Test email.

gmayor
06-09-2016, 06:49 AM
Ah! I thought it an odd requirement. If no-one has picked it up overnight, I will address it tomorrow.

New1992
06-09-2016, 05:47 PM
Never mind, I found another way to do it. Instead I am copying the body of the email I want to reply to and making the "from" and "sent" sections on my own.