Get address from body of message macro ?

  • Thread starter Thread starter Stacy
  • Start date Start date
S

Stacy

People often forward me mail that I have to respond to. Usually its in the
following format.
Note that the {end of line}is not in email Im just telling you this because
it may make it easier to find the end of the line rather than the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail message for the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message into word. It
just searches for the first [ then selects from there to the end of the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email address
from the body and then create a reply email based on the mail it got the
email address from but. That may be a little too involved.

Regards
 
Hi Stacy,

why don´t you take the address from the SenderAddress property? And for
the reply, why not just call the MailItem.Reply method?
 
Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the info in the
header of the mail is from the most recent sender not the one who originally
sent it.

As I had mentioned the only info I get is what is in the email its self. The
header has no information on the original sender. So I want a macro which
can extract info from the body of the message. I could cut the mail and
paste it into word and then find it, because I can do this in word. But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body of the
message? It seems to me that due to MS effort to stop virus's so much is not
available in Outlook.

Regards
Stacy

Michael Bauer said:
Hi Stacy,

why don´t you take the address from the SenderAddress property? And for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


Stacy said:
People often forward me mail that I have to respond to. Usually its in the
following format.
Note that the {end of line}is not in email Im just telling you this because
it may make it easier to find the end of the line rather than the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail message for the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message into word. It
just searches for the first [ then selects from there to the end of the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email address
from the body and then create a reply email based on the mail it got the
email address from but. That may be a little too involved.

Regards
 
Hi Stacy,

for searching strings in the message please use the Instr function. It
returns the start position. This can be used to determining the start
and end positions of a specific string. The string itself you can then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Stacy said:
Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the info in the
header of the mail is from the most recent sender not the one who originally
sent it.

As I had mentioned the only info I get is what is in the email its self. The
header has no information on the original sender. So I want a macro which
can extract info from the body of the message. I could cut the mail and
paste it into word and then find it, because I can do this in word. But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body of the
message? It seems to me that due to MS effort to stop virus's so much is not
available in Outlook.

Regards
Stacy

Michael Bauer said:
Hi Stacy,

why don´t you take the address from the SenderAddress property? And for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


Stacy said:
People often forward me mail that I have to respond to. Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling you
this
because
it may make it easier to find the end of the line rather than the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail message
for
the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message into
word.
It
just searches for the first [ then selects from there to the end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email address
from the body and then create a reply email based on the mail it
got
the
email address from but. That may be a little too involved.

Regards
 
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content) to your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


Stacy said:
I have writen the following code based the advice given here. (Please dont
criticise it too much im not an expert, I just do one off things to help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and will give you
'the positions of the variables.
'However it only does it in the script it does not do it in a piece of mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Michael Bauer said:
Hi Stacy,

for searching strings in the message please use the Instr function. It
returns the start position. This can be used to determining the start
and end positions of a specific string. The string itself you can then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Stacy said:
Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the
info in
the
header of the mail is from the most recent sender not the one who originally
sent it.

As I had mentioned the only info I get is what is in the email its self. The
header has no information on the original sender. So I want a
macro
which
can extract info from the body of the message. I could cut the
mail
and
paste it into word and then find it, because I can do this in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body
of
the
message? It seems to me that due to MS effort to stop virus's so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling you this
because
it may make it easier to find the end of the line rather than the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail
message
for
the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message
into
word.
It
just searches for the first [ then selects from there to the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email
address
from the body and then create a reply email based on the mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
I have writen the following code based the advice given here. (Please dont
criticise it too much im not an expert, I just do one off things to help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and will give you
'the positions of the variables.
'However it only does it in the script it does not do it in a piece of mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Michael Bauer said:
Hi Stacy,

for searching strings in the message please use the Instr function. It
returns the start position. This can be used to determining the start
and end positions of a specific string. The string itself you can then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Stacy said:
Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the info in the
header of the mail is from the most recent sender not the one who originally
sent it.

As I had mentioned the only info I get is what is in the email its self. The
header has no information on the original sender. So I want a macro which
can extract info from the body of the message. I could cut the mail and
paste it into word and then find it, because I can do this in word. But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body of the
message? It seems to me that due to MS effort to stop virus's so much is not
available in Outlook.

Regards
Stacy

Michael Bauer said:
Hi Stacy,

why don´t you take the address from the SenderAddress property? And for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to. Usually its in
the
following format.
Note that the {end of line}is not in email Im just telling you this
because
it may make it easier to find the end of the line rather than the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail message for
the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message into word.
It
just searches for the first [ then selects from there to the end of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email
address
from the body and then create a reply email based on the mail it got
the
email address from but. That may be a little too involved.

Regards
 
Thanks again. I have tried with my simple understanding to get this to work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Michael Bauer said:
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content) to your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


Stacy said:
I have writen the following code based the advice given here. (Please dont
criticise it too much im not an expert, I just do one off things to help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and will give you
'the positions of the variables.
'However it only does it in the script it does not do it in a piece of mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Michael Bauer said:
Hi Stacy,

for searching strings in the message please use the Instr function. It
returns the start position. This can be used to determining the start
and end positions of a specific string. The string itself you can then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the info in
the
header of the mail is from the most recent sender not the one who
originally
sent it.

As I had mentioned the only info I get is what is in the email its
self. The
header has no information on the original sender. So I want a macro
which
can extract info from the body of the message. I could cut the mail
and
paste it into word and then find it, because I can do this in word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body of
the
message? It seems to me that due to MS effort to stop virus's so much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress property? And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to. Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling you
this
because
it may make it easier to find the end of the line rather than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail message
for
the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message into
word.
It
just searches for the first [ then selects from there to the end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email
address
from the body and then create a reply email based on the mail it
got
the
email address from but. That may be a little too involved.

Regards
 
Hi Stacy,

where do you get this error?
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library do you
use the DataObject?

--
Viele Grüße
Michael Bauer


Stacy said:
Thanks again. I have tried with my simple understanding to get this to work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Michael Bauer said:
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content) to your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


Stacy said:
I have writen the following code based the advice given here.
(Please
dont
criticise it too much im not an expert, I just do one off things
to
help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and
will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a
piece of
mail
Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr
function.
It
returns the start position. This can be used to determining the start
and end positions of a specific string. The string itself you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the info in
the
header of the mail is from the most recent sender not the one who
originally
sent it.

As I had mentioned the only info I get is what is in the email its
self. The
header has no information on the original sender. So I want a macro
which
can extract info from the body of the message. I could cut the mail
and
paste it into word and then find it, because I can do this in word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the
body
of
the
message? It seems to me that due to MS effort to stop virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress
property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to. Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling you
this
because
it may make it easier to find the end of the line rather than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail message
for
the
first email address in that mail and then copy it to clipboard.
Then I can paste it where I want. The first email message is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the
message
into
word.
It
just searches for the first [ then selects from there to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the email
address
from the body and then create a reply email based on the
mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
Ok, do you execute the macro from within Word? In that case Application
would reference the Word Application object, which hasn´t a Session
property, and that would raise the error.

You´d need a variable for the reference on the Outlook Application
object. E.g.:

On Error Resume Next
Dim olApp as Outlook.Application
Set olApp = GetObject(,"Outlook.Application")
If Err.Number Then
Set olApp = CreateObject((,"Outlook.Application")
Endif

--
Viele Grüße
Michael Bauer


Stacy said:
Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0 fm20.dll"
But the clipboard works fine in my first sample I submitted. Its at the
above line it seems to die.

Regards


Michael Bauer said:
Hi Stacy,

where do you get this error?
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library do you
use the DataObject?

--
Viele Grüße
Michael Bauer


Stacy said:
Thanks again. I have tried with my simple understanding to get
this to
work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content)
to
your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given here. (Please
dont
criticise it too much im not an expert, I just do one off
things
to
help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr function.
It
returns the start position. This can be used to determining the
start
and end positions of a specific string. The string itself
you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the
info in
the
header of the mail is from the most recent sender not the
one
who
originally
sent it.

As I had mentioned the only info I get is what is in the
email
its
self. The
header has no information on the original sender. So I want a
macro
which
can extract info from the body of the message. I could cut the
mail
and
paste it into word and then find it, because I can do this in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in
the
body
of
the
message? It seems to me that due to MS effort to stop
virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just
telling
you
this
because
it may make it easier to find the end of the line
rather
than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail
message
for
the
first email address in that mail and then copy it to
clipboard.
Then I can paste it where I want. The first email
message
is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message
into
word.
It
just searches for the first [ then selects from there
to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the
email
address
from the body and then create a reply email based on
the
mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0 fm20.dll"
But the clipboard works fine in my first sample I submitted. Its at the
above line it seems to die.

Regards


Michael Bauer said:
Hi Stacy,

where do you get this error?
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library do you
use the DataObject?

--
Viele Grüße
Michael Bauer


Stacy said:
Thanks again. I have tried with my simple understanding to get this to work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Michael Bauer said:
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content) to your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given here. (Please
dont
criticise it too much im not an expert, I just do one off things to
help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr function.
It
returns the start position. This can be used to determining the
start
and end positions of a specific string. The string itself you can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the
info in
the
header of the mail is from the most recent sender not the one who
originally
sent it.

As I had mentioned the only info I get is what is in the email its
self. The
header has no information on the original sender. So I want a
macro
which
can extract info from the body of the message. I could cut the
mail
and
paste it into word and then find it, because I can do this in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body
of
the
message? It seems to me that due to MS effort to stop virus's so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling you
this
because
it may make it easier to find the end of the line rather than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail
message
for
the
first email address in that mail and then copy it to
clipboard.
Then I can paste it where I want. The first email message is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message
into
word.
It
just searches for the first [ then selects from there to the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the
email
address
from the body and then create a reply email based on the mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
PS

Perhaps I dont have some library loaded that Im suppose to ?? Does your code
require a library ??

Regards
Stacy

Michael Bauer said:
Hi Stacy,

where do you get this error?
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library do you
use the DataObject?

--
Viele Grüße
Michael Bauer


Stacy said:
Thanks again. I have tried with my simple understanding to get this to work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Michael Bauer said:
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content) to your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given here. (Please
dont
criticise it too much im not an expert, I just do one off things to
help me
make my life a little easier.) The advice was very helpfull. Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr function.
It
returns the start position. This can be used to determining the
start
and end positions of a specific string. The string itself you can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the
info in
the
header of the mail is from the most recent sender not the one who
originally
sent it.

As I had mentioned the only info I get is what is in the email its
self. The
header has no information on the original sender. So I want a
macro
which
can extract info from the body of the message. I could cut the
mail
and
paste it into word and then find it, because I can do this in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the body
of
the
message? It seems to me that due to MS effort to stop virus's so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling you
this
because
it may make it easier to find the end of the line rather than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail
message
for
the
first email address in that mail and then copy it to
clipboard.
Then I can paste it where I want. The first email message is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the message
into
word.
It
just searches for the first [ then selects from there to the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the
email
address
from the body and then create a reply email based on the mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
The way I run it is, I open a piece of mail. Go to macros and run the macro.
When I get it working I will simply add the macro to the toolbar of Outlook
2000.

I do not run it in Word or anything like that.

Regards

Stacy

Michael Bauer said:
Ok, do you execute the macro from within Word? In that case Application
would reference the Word Application object, which hasn´t a Session
property, and that would raise the error.

You´d need a variable for the reference on the Outlook Application
object. E.g.:

On Error Resume Next
Dim olApp as Outlook.Application
Set olApp = GetObject(,"Outlook.Application")
If Err.Number Then
Set olApp = CreateObject((,"Outlook.Application")
Endif

--
Viele Grüße
Michael Bauer


Stacy said:
Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0 fm20.dll"
But the clipboard works fine in my first sample I submitted. Its at the
above line it seems to die.

Regards


Michael Bauer said:
Hi Stacy,

where do you get this error?

objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library do you
use the DataObject?

--
Viele Grüße
Michael Bauer


Thanks again. I have tried with my simple understanding to get this to
work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Hi Stacy,

this returns a reference on the first selected item in a mail folder
(assuming it´s really a MailItem) and writes its body (content) to
your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given here.
(Please
dont
criticise it too much im not an expert, I just do one off things
to
help me
make my life a little easier.) The advice was very helpfull.
Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my
debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and
will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a
piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." & _
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr
function.
It
returns the start position. This can be used to determining the
start
and end positions of a specific string. The string itself you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of the
info in
the
header of the mail is from the most recent sender not the one
who
originally
sent it.

As I had mentioned the only info I get is what is in the email
its
self. The
header has no information on the original sender. So I want a
macro
which
can extract info from the body of the message. I could cut the
mail
and
paste it into word and then find it, because I can do this in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in the
body
of
the
message? It seems to me that due to MS effort to stop virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress
property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling
you
this
because
it may make it easier to find the end of the line rather
than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open mail
message
for
the
first email address in that mail and then copy it to
clipboard.
Then I can paste it where I want. The first email message
is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the
message
into
word.
It
just searches for the first [ then selects from there to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take the
email
address
from the body and then create a reply email based on the
mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
Hi Stacy,

I´m so sorry, it was my fault. Please write it without "Session":

Set oMail = Application.ActiveExplorer.Selection(1)


--
Viele Grüße
Michael Bauer


Stacy said:
The way I run it is, I open a piece of mail. Go to macros and run the macro.
When I get it working I will simply add the macro to the toolbar of Outlook
2000.

I do not run it in Word or anything like that.

Regards

Stacy

Michael Bauer said:
Ok, do you execute the macro from within Word? In that case Application
would reference the Word Application object, which hasn´t a Session
property, and that would raise the error.

You´d need a variable for the reference on the Outlook Application
object. E.g.:

On Error Resume Next
Dim olApp as Outlook.Application
Set olApp = GetObject(,"Outlook.Application")
If Err.Number Then
Set olApp = CreateObject((,"Outlook.Application")
Endif

--
Viele Grüße
Michael Bauer


Stacy said:
Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0 fm20.dll"
But the clipboard works fine in my first sample I submitted. Its
at
the
above line it seems to die.

Regards


Hi Stacy,

where do you get this error?

objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library
do
you
use the DataObject?

--
Viele Grüße
Michael Bauer


Thanks again. I have tried with my simple understanding to get this to
work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Hi Stacy,

this returns a reference on the first selected item in a
mail
folder
(assuming it´s really a MailItem) and writes its body
(content)
to
your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given here.
(Please
dont
criticise it too much im not an expert, I just do one off things
to
help me
make my life a little easier.) The advice was very helpfull.
Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and
vola
it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my
debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and
will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a
piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 &
"." &
_
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr
function.
It
returns the start position. This can be used to
determining
the
start
and end positions of a specific string. The string
itself
you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but
all of
the
info in
the
header of the mail is from the most recent sender not
the
one
who
originally
sent it.

As I had mentioned the only info I get is what is in
the
email
its
self. The
header has no information on the original sender. So I want a
macro
which
can extract info from the body of the message. I could
cut
the
mail
and
paste it into word and then find it, because I can do
this
in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******]
in
the
body
of
the
message? It seems to me that due to MS effort to stop virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress
property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to
respond
to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just telling
you
this
because
it may make it easier to find the end of the line rather
than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an
open
mail
message
for
the
first email address in that mail and then copy it to
clipboard.
Then I can paste it where I want. The first email message
is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the
message
into
word.
It
just searches for the first [ then selects from
there
to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could
take
the
email
address
from the body and then create a reply email based
on
the
mail
it
got
the
email address from but. That may be a little too involved.

Regards
 
Michael thanks for your help. Your elimination of session certainly did the
trick. I can now successfully pull just the email address out of the email.

While it works perfectly, I have had to play with the variable text result
as it seems to be picking up the next 2 lines in the email.
JustEmailAddress well isn't. It seems to be picking up the three lines int
he body of the email that were forwarded to me.
---------------the 3 lines it pick up in the body---------------------
(e-mail address removed)]
Sent: Thursday, March 10, 2005 11:55 AM
To: RAIDZONE Sales;
--------------------snip----------------
After fiddleing with it and using Instr again and left I got the result I
wanted. I'm going to continue to play with it a bit. Perhaps removing end of
lines ?? Any advice. The second instr etc does clean it up though.

Again thank you.

Stacy
---snip--
Sub aaTest_InStr4CleanCopy()
'March 16 2005

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject
Dim oMail As Outlook.MailItem

Set oMail = Application.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'Serch for
SearchChar1 = "["
SearchChar2 = "]"

'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

'First try at getting data
JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 )

'Second try and now clean things up.
MyPos3 = InStr(1, JustEmailAddress, SearchChar1, 1)
MyPos4 = InStr(1, JustEmailAddress, SearchChar2, 1)
AddressFinal = Left(JustEmailAddress, MyPos4 - 1)

'Display address if you want
MsgBox "Just the email address is " & AddressFinal

'Put address in clipboard .. Microsoft Forms 2.0 Object Library must be
referenced.
objDataObj.SetText JustEmailAddress3
objDataObj.PutInClipboard

End Sub
--snip--
Michael Bauer said:
Hi Stacy,

I´m so sorry, it was my fault. Please write it without "Session":

Set oMail = Application.ActiveExplorer.Selection(1)


--
Viele Grüße
Michael Bauer


Stacy said:
The way I run it is, I open a piece of mail. Go to macros and run the macro.
When I get it working I will simply add the macro to the toolbar of Outlook
2000.

I do not run it in Word or anything like that.

Regards

Stacy

Michael Bauer said:
Ok, do you execute the macro from within Word? In that case Application
would reference the Word Application object, which hasn´t a Session
property, and that would raise the error.

You´d need a variable for the reference on the Outlook Application
object. E.g.:

On Error Resume Next
Dim olApp as Outlook.Application
Set olApp = GetObject(,"Outlook.Application")
If Err.Number Then
Set olApp = CreateObject((,"Outlook.Application")
Endif

--
Viele Grüße
Michael Bauer


Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0
fm20.dll"
But the clipboard works fine in my first sample I submitted. Its at
the
above line it seems to die.

Regards


Hi Stacy,

where do you get this error?

objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library do
you
use the DataObject?

--
Viele Grüße
Michael Bauer


Thanks again. I have tried with my simple understanding to get
this to
work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Hi Stacy,

this returns a reference on the first selected item in a mail
folder
(assuming it´s really a MailItem) and writes its body (content)
to
your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given here.
(Please
dont
criticise it too much im not an expert, I just do one off
things
to
help me
make my life a little easier.) The advice was very helpfull.
Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of mail?
In other words open the mail message, click the macro and vola
it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in my
debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets and
will
give you
'the positions of the variables.
'However it only does it in the script it does not do it in a
piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 & "." &
_
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr
function.
It
returns the start position. This can be used to determining
the
start
and end positions of a specific string. The string itself
you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for
samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but all of
the
info in
the
header of the mail is from the most recent sender not the
one
who
originally
sent it.

As I had mentioned the only info I get is what is in the
email
its
self. The
header has no information on the original sender. So I
want a
macro
which
can extract info from the body of the message. I could cut
the
mail
and
paste it into word and then find it, because I can do this
in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******] in
the
body
of
the
message? It seems to me that due to MS effort to stop
virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress
property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond
to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just
telling
you
this
because
it may make it easier to find the end of the line
rather
than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an open
mail
message
for
the
first email address in that mail and then copy it to
clipboard.
Then I can paste it where I want. The first email
message
is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste the
message
into
word.
It
just searches for the first [ then selects from there
to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could take
the
email
address
from the body and then create a reply email based on
the
mail
it
got
the
email address from but. That may be a little too
involved.

Regards
 
Hi Stacy,
From: Joe Wu [mailto:[email protected]] {end of line}

if the mail contains the above line and assuming "[mailto:" doesn´t
exist on a former position, I´d search in this way:

Dim lPos_1 as Long
Dim lPos_2 as Long
Dim sBody as String
Dim sEMail as String

sBody=oMail.Body

' search here vbTextCompare because it isn´t case-sensitive
lPos_1=Instr(1, sBody, "[mailto:", vbTextCompare)
If lPos_1 Then
lPos_1=lPos_1+Len("[mailto:")
lPos_2=Instr(lPos_1, sBody, "]")
If lPos_2 Then
sEMail=Mid$(sBody, lpos_1, lPos_2-lPos_1)
Endif
Endif

--
Viele Grüße
Michael Bauer


Stacy said:
Michael thanks for your help. Your elimination of session certainly did the
trick. I can now successfully pull just the email address out of the email.

While it works perfectly, I have had to play with the variable text result
as it seems to be picking up the next 2 lines in the email.
JustEmailAddress well isn't. It seems to be picking up the three lines int
he body of the email that were forwarded to me.
---------------the 3 lines it pick up in the body---------------------
(e-mail address removed)]
Sent: Thursday, March 10, 2005 11:55 AM
To: RAIDZONE Sales;
--------------------snip----------------
After fiddleing with it and using Instr again and left I got the result I
wanted. I'm going to continue to play with it a bit. Perhaps removing end of
lines ?? Any advice. The second instr etc does clean it up though.

Again thank you.

Stacy
---snip--
Sub aaTest_InStr4CleanCopy()
'March 16 2005

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject
Dim oMail As Outlook.MailItem

Set oMail = Application.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'Serch for
SearchChar1 = "["
SearchChar2 = "]"

'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

'First try at getting data
JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 )

'Second try and now clean things up.
MyPos3 = InStr(1, JustEmailAddress, SearchChar1, 1)
MyPos4 = InStr(1, JustEmailAddress, SearchChar2, 1)
AddressFinal = Left(JustEmailAddress, MyPos4 - 1)

'Display address if you want
MsgBox "Just the email address is " & AddressFinal

'Put address in clipboard .. Microsoft Forms 2.0 Object Library must be
referenced.
objDataObj.SetText JustEmailAddress3
objDataObj.PutInClipboard

End Sub
--snip--
Michael Bauer said:
Hi Stacy,

I´m so sorry, it was my fault. Please write it without "Session":

Set oMail = Application.ActiveExplorer.Selection(1)


--
Viele Grüße
Michael Bauer


Stacy said:
The way I run it is, I open a piece of mail. Go to macros and run
the
macro.
When I get it working I will simply add the macro to the toolbar
of
Outlook
2000.

I do not run it in Word or anything like that.

Regards

Stacy

Ok, do you execute the macro from within Word? In that case Application
would reference the Word Application object, which hasn´t a Session
property, and that would raise the error.

You´d need a variable for the reference on the Outlook Application
object. E.g.:

On Error Resume Next
Dim olApp as Outlook.Application
Set olApp = GetObject(,"Outlook.Application")
If Err.Number Then
Set olApp = CreateObject((,"Outlook.Application")
Endif

--
Viele Grüße
Michael Bauer


Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0
fm20.dll"
But the clipboard works fine in my first sample I submitted.
Its
at
the
above line it seems to die.

Regards


Hi Stacy,

where do you get this error?

objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which
library
do
you
use the DataObject?

--
Viele Grüße
Michael Bauer


Thanks again. I have tried with my simple understanding to get
this to
work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Hi Stacy,

this returns a reference on the first selected item in a mail
folder
(assuming it´s really a MailItem) and writes its body (content)
to
your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice
given
here.
(Please
dont
criticise it too much im not an expert, I just do one off
things
to
help me
make my life a little easier.) The advice was very helpfull.
Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece
of
mail?
In other words open the mail message, click the macro
and
vola
it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help
in
my
debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the
brackets
and
will
give you
'the positions of the variables.
'However it only does it in the script it does not do
it
in a
piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1
&
"." &
_
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8,
MyPos2 -
9)
MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the Instr
function.
It
returns the start position. This can be used to determining
the
start
and end positions of a specific string. The string itself
you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for
samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information
but
all of
the
info in
the
header of the mail is from the most recent sender
not
the
one
who
originally
sent it.

As I had mentioned the only info I get is what is
in
the
email
its
self. The
header has no information on the original sender. So I
want a
macro
which
can extract info from the body of the message. I
could
cut
the
mail
and
paste it into word and then find it, because I can
do
this
in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for
[mailto:*******]
in
the
body
of
the
message? It seems to me that due to MS effort to stop
virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the SenderAddress
property?
And
for
the reply, why not just call the MailItem.Reply method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to respond
to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just
telling
you
this
because
it may make it easier to find the end of the line
rather
than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end
of
line}
Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search
an
open
mail
message
for
the
first email address in that mail and then copy
it
to
clipboard.
Then I can paste it where I want. The first email
message
is
delineated by
square brackets [ ]

I can do this easily in a word macro if I
paste
the
message
into
word.
It
just searches for the first [ then selects
from
there
to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it
could
take
the
email
address
from the body and then create a reply email
based
on
the
mail
it
got
the
email address from but. That may be a little too
involved.

Regards
 
I see yes that's considerably cleaner and concise than my attempt. It always
amazes me how there are so many ways to do the same kind of thing.

Thank you very much .

Stacy
Michael Bauer said:
Hi Stacy,
From: Joe Wu [mailto:[email protected]] {end of line}

if the mail contains the above line and assuming "[mailto:" doesn´t
exist on a former position, I´d search in this way:

Dim lPos_1 as Long
Dim lPos_2 as Long
Dim sBody as String
Dim sEMail as String

sBody=oMail.Body

' search here vbTextCompare because it isn´t case-sensitive
lPos_1=Instr(1, sBody, "[mailto:", vbTextCompare)
If lPos_1 Then
lPos_1=lPos_1+Len("[mailto:")
lPos_2=Instr(lPos_1, sBody, "]")
If lPos_2 Then
sEMail=Mid$(sBody, lpos_1, lPos_2-lPos_1)
Endif
Endif

--
Viele Grüße
Michael Bauer


Stacy said:
Michael thanks for your help. Your elimination of session certainly did the
trick. I can now successfully pull just the email address out of the email.

While it works perfectly, I have had to play with the variable text result
as it seems to be picking up the next 2 lines in the email.
JustEmailAddress well isn't. It seems to be picking up the three lines int
he body of the email that were forwarded to me.
---------------the 3 lines it pick up in the body---------------------
(e-mail address removed)]
Sent: Thursday, March 10, 2005 11:55 AM
To: RAIDZONE Sales;
--------------------snip----------------
After fiddleing with it and using Instr again and left I got the result I
wanted. I'm going to continue to play with it a bit. Perhaps removing end of
lines ?? Any advice. The second instr etc does clean it up though.

Again thank you.

Stacy
---snip--
Sub aaTest_InStr4CleanCopy()
'March 16 2005

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject
Dim oMail As Outlook.MailItem

Set oMail = Application.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'Serch for
SearchChar1 = "["
SearchChar2 = "]"

'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

'First try at getting data
JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 )

'Second try and now clean things up.
MyPos3 = InStr(1, JustEmailAddress, SearchChar1, 1)
MyPos4 = InStr(1, JustEmailAddress, SearchChar2, 1)
AddressFinal = Left(JustEmailAddress, MyPos4 - 1)

'Display address if you want
MsgBox "Just the email address is " & AddressFinal

'Put address in clipboard .. Microsoft Forms 2.0 Object Library must be
referenced.
objDataObj.SetText JustEmailAddress3
objDataObj.PutInClipboard

End Sub
--snip--
Michael Bauer said:
Hi Stacy,

I´m so sorry, it was my fault. Please write it without "Session":

Set oMail = Application.ActiveExplorer.Selection(1)


--
Viele Grüße
Michael Bauer


The way I run it is, I open a piece of mail. Go to macros and run the
macro.
When I get it working I will simply add the macro to the toolbar of
Outlook
2000.

I do not run it in Word or anything like that.

Regards

Stacy

Ok, do you execute the macro from within Word? In that case
Application
would reference the Word Application object, which hasn´t a Session
property, and that would raise the error.

You´d need a variable for the reference on the Outlook Application
object. E.g.:

On Error Resume Next
Dim olApp as Outlook.Application
Set olApp = GetObject(,"Outlook.Application")
If Err.Number Then
Set olApp = CreateObject((,"Outlook.Application")
Endif

--
Viele Grüße
Michael Bauer


Actually It stops near the top when it tried to process

Set oMail = Application.Session.ActiveExplorer.Selection(1)

Thats when I get the error I mentioned.

To answer your question I think the library is in "MS Forms 2.0
fm20.dll"
But the clipboard works fine in my first sample I submitted. Its
at
the
above line it seems to die.

Regards


Hi Stacy,

where do you get this error?

objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

I suppose one of this lines causes the error. From which library
do
you
use the DataObject?

--
Viele Grüße
Michael Bauer


Thanks again. I have tried with my simple understanding to get
this to
work
but can't seem to get it right.
Here is what I think should work. But I get an error message :

Run-time error '838'
Object doesn't support this property or method

-- code --

Sub aaTest_InStr4()

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

Dim oMail As Outlook.MailItem

Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body

'''SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 - 9)

MsgBox "Just the email address is " & JustEmailAddress


'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard

End Sub
-- code--
Hi Stacy,

this returns a reference on the first selected item in a
mail
folder
(assuming it´s really a MailItem) and writes its body
(content)
to
your
variable:

Dim oMail as Outlook.MailItem
Set oMail = Application.Session.ActiveExplorer.Selection(1)

SearchString1 = oMail.Body


--
Viele Grüße
Michael Bauer


I have writen the following code based the advice given
here.
(Please
dont
criticise it too much im not an expert, I just do one off
things
to
help me
make my life a little easier.) The advice was very
helpfull.
Thanks.
Now I want to get it to actually run on the body of mail.

How can I get this code to run on the body of a piece of
mail?
In other words open the mail message, click the macro and
vola
it
finds the
first email address surounded by [ ]

Thank you.

Stacy

Ps there is lots of msg boxes because I find they help in
my
debugging
process.

----- code -----
Sub aaTest_InStr4()
'March 15 2005
'Using the Instr Function this code looks for the brackets
and
will
give you
'the positions of the variables.
'However it only does it in the script it does not do it
in a
piece of
mail

Dim SearchString1, SearchChar1, SearchChar2, MyPos1, _
objDataObj As New DataObject

SearchString1 = "[mailto:[email protected]]"
SearchChar1 = "["
SearchChar2 = "]"
'Position string is found in
MyPos1 = InStr(1, SearchString1, SearchChar1, 1)
MyPos2 = InStr(1, SearchString1, SearchChar2, 1)

MsgBox "The [ bracket is found at position " & MyPos1 &
"." &
_
" The ] bracket is found at position " & MyPos2 & "."

FullEmailAddress = Mid(SearchString1, MyPos1, MyPos2)

MsgBox "The full email address is " & FullEmailAddress

JustEmailAddress = Mid(SearchString1, MyPos1 + 8, MyPos2 -
9)

MsgBox "Just the email address is " & JustEmailAddress

'Put address in clipboard
objDataObj.SetText JustEmailAddress
objDataObj.PutInClipboard
End Sub

--- Code ---



Hi Stacy,

for searching strings in the message please use the
Instr
function.
It
returns the start position. This can be used to
determining
the
start
and end positions of a specific string. The string
itself
you
can
then
get with the Mid$, Left$, or Right$ functions.

Please just type in the function names and press F1 for
samples.

--
Viele Grüße
Michael Bauer


Michael,

Because the mail has been forwarded to me.

That is, they have forwarded me the information but
all of
the
info in
the
header of the mail is from the most recent sender not
the
one
who
originally
sent it.

As I had mentioned the only info I get is what is in
the
email
its
self. The
header has no information on the original sender. So I
want a
macro
which
can extract info from the body of the message. I could
cut
the
mail
and
paste it into word and then find it, because I can do
this
in
word.
But I
don't know how to do it in Outllook 2000 mail message.
Can you write a macro to search for [mailto:*******]
in
the
body
of
the
message? It seems to me that due to MS effort to stop
virus's
so
much
is not
available in Outlook.

Regards
Stacy

Hi Stacy,

why don´t you take the address from the
SenderAddress
property?
And
for
the reply, why not just call the MailItem.Reply
method?

--
Viele Grüße
Michael Bauer


People often forward me mail that I have to
respond
to.
Usually
its in
the
following format.
Note that the {end of line}is not in email Im just
telling
you
this
because
it may make it easier to find the end of the line
rather
than
the ]
-----snip---
John can you follow up on this for me.

Fred

-----Original Message-----

From: Joe Wu [mailto:[email protected]] {end of
line}

Sent: Tuesday, March 08, 2005 12:41 PM

To: Info Sales; Evals

Subject: Eval Request - form

-----snip--

Can someone provide a macro that will search an
open
mail
message
for
the
first email address in that mail and then copy it
to
clipboard.
Then I can paste it where I want. The first email
message
is
delineated by
square brackets [ ]

I can do this easily in a word macro if I paste
the
message
into
word.
It
just searches for the first [ then selects from
there
to
the
end
of
the line
and copies it to clipboard.

I suppose what would rally be nice is if it could
take
the
email
address
from the body and then create a reply email based
on
the
mail
it
got
the
email address from but. That may be a little too
involved.

Regards
 
Back
Top