email body without "HYPERLINK" ( vba )

Status
Not open for further replies.

skrz

Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Hi,

a sample email :

Hello,

I'm sending to you ....

www.google.com

then we select in Outlook and run vba code :

SelectMail = Outlook.ActiveExplorer.Selection.Item(1)

strEmail = SelectMail.body

If we display strEmail ( msgbox )

then we get :



Hello,

I'm sending to you ....

HYPERLINK"
http://google.com"www.google.com

how to get rid of expression HYPERLINKhttp://google.com

I need only text message as string ( the same as we select email contents and copy - paste to notepad )

Thanks



 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Re: email body without "HYPERLINK" ( vba )

Actually, if its in the Msgbox only, not in the message, Alt+F9 won't help. (But I've never seen hyperlink code in a msgbox...) HTMLbody *should* work to get the rendered text, not the underlying code.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That looks like the hyperlink field code. I've not seen it picked up and used in a msgbox though, that seems odd - my tests all use the google.com<http://www.google.com> format for urls - still not what you want (I assume)...

Try this - you'll need to reference MSForms - in VBA Editor, go to Tools, References and add a check to the MSForms entry.

Sub testskrz()

Dim selectmail As MailItem

Dim DataObj As MSForms.DataObject
Set selectmail = ActiveExplorer.Selection.Item(1)
Set DataObj = New MSForms.DataObject
DataObj.SetText selectmail.Body
DataObj.PutInClipboard
DataObj.GetFromClipboard

MsgBox DataObj.GetText(1)

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It's still coming up with the word hyperlink? Is this an RTF formatted message? Try RTFBody.






The macro I posted gets me this on an HTML message:




macro-results.jpg
 
Status
Not open for further replies.
Top