Email hyperlink to text

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Email hyperlink to text

Post by Pat »

I have emails where i am trying to pickup the email address embedded in the body.
The email addresses are typically:
"mailto:xxxxx@iprimus.com.au"xxxxx@iprimus.com.au
is there a clever way to extract the email address from that or am i up for coding to extract it?

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Email hyperlink to text

Post by HansV »

You have posted this in the Access forum. Are the e-mails stored in Access, or should Access check your inbox, or ...?
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Email hyperlink to text

Post by Pat »

This is in Access using Outlook automation to check the inbox.

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Email hyperlink to text

Post by HansV »

1) Will there be one e-mail address in the body or several ones?
2) Will the e-mail address always be listed in the form "mailto:address"adress ?
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Email hyperlink to text

Post by Pat »

1. i need to first email address i come to.
2. yes, it would appear so

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Email hyperlink to text

Post by HansV »

Assuming that you know how to automate Outlook and set a string variable strBody to the Body of an Outlook.MailItem object:

Code: Select all

  Dim strBody As String
  Dim intPos1 As String
  Dim intPos2 As String
  Dim strMailAddress As String

  ...

  strBody = ...
  intPos1 = InStr(strBody, Chr(34) & "mailto:")
  If intPos1 > 0 Then
    intPos2 = InStr(intPos1 + 8, strBody, Chr(34))
    If intPos2 > 0 Then
      strMailAddress = Mid(strBody, intPos1 + 8, intPos2 - intPos1 - 8)
    End If
  End If
  ...
If strMailAddress is an empty string "" at the end of this code fragment, no e-mail address was found.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Email hyperlink to text

Post by Pat »

Thanks but i have already coded that, i was wondering if there was a more elegant way of doing it.

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Email hyperlink to text

Post by HansV »

Not that I know of.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Email hyperlink to text

Post by Pat »

Didn't think so, but then again it's amazing what you come up with from time to time.

Thanks again Hans

grovelli
4StarLounger
Posts: 528
Joined: 26 Jan 2010, 15:14

Re: Email hyperlink to text

Post by grovelli »

Hi Pat, if you viewed your inbox folder as a linked table, couldn't you use SQL rather than VBA to process it?

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Email hyperlink to text

Post by HansV »

Extracting the e-mail address in a query would be complicated but possible, but I don't know how Pat wants to use the e-mail addresses.
Best wishes,
Hans