Re: Send an Auto Response to an email address held in the body

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Michael, you are a STAR!!

Got it working great. Thank you very much.

Last question (I hope) is there a quick easy way to confirm that the
extracted string contains a valid email address?

Again many, many thanks,
Tim.

"Michael Bauer [MVP - Outlook]" wrote:



Please show how your code actually looks like.

After editing code you need to execute the Application_Startup procedure
manually (place the cursor into it and press f5) or restart Outlook.
Additionally, VBA will be executed only if the security settings are set to
medium or low (toolbar, click Tools/Macro/Security), or if you certify the
project.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize Outlook email:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>


Am Sat, 16 Jun 2007 02:01:00 -0700 schrieb Timjohn:

Hi Michael,
I've managed to get some vb working well in excel so I'm not thick but I
just can't seem to get my head round this. I know what I want to do and I
think I see what your code says but beyond that I seem to be lost. I've
copied your code into ThisOutlookSession, added an 'if Item.Subject =
"Reply
Needed" then msgbox' in the parsemail sub just as a test, restarted
Outlook
but nothing happens when mail arrives. I moved the msgbox outside the
loop
but still nothing. If you have time your help is very much appreciated.
Warm regards,
Tim

"Michael Bauer [MVP - Outlook]" wrote:



Copy that into ThisOutlookSession:

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
ParseMail Item
End If
End Sub

Public Sub ParseMail(Mail As Outlook.MailItem)
' continue
End Sub

In ParseMail, play with the mentioned functions to find and extract the
address from the Mail.Body property.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize Outlook email:

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Fri, 15 Jun 2007 00:07:03 -0700 schrieb Timjohn:

Thanks Michael, that looks exactly what I want. Now the awkward bit. I
opened VB from within Outlook, opened Project1 and then
ThisOutlookSession,
but I don't know where to put the code, don't really know where to
start!
I'll learn as I go but if you have time could you help!

Thanks, Tim
"Michael Bauer [MVP - Outlook]" wrote:



The ItemAdd event of the Inbox tells you when a new item arrives; a
sample
is in the VBA help file.

In that event compare the item's Subject property with what you're
looking
for. An email address can be found by searching with the InStr function
for
a "@" character:

Dim pos&
pos=Instr(Item.Body, "@")

tells you the position of that character. If it's found start at that
position and use the Instr function again to find the right
demarcation;
you
must know what character that is, usually "'", or ">", or " ".

Then start at pos again and use the InStrRev function, which searches
backwards, that is it will find the left demarcation. If that's done
you
can
use the Mid function to extract the address.

Call Application.CreateItem to create a new MailItem and then the
item's
Recipients.Add function to add the address (write Subject and Body as
well)
and call Send.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize Outlook email:


<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Thu, 14 Jun 2007 15:02:01 -0700 schrieb Timjohn:

Hi,
I receive emails from a web site and the respondents email address is
within
the body of the email, the email itself comes through a host
somewhere.
I
want to be able to send a 'Thanks for your Interest' email as soon as
my
inbox receives the request. All the emails that arrive have the same
subject
line so I can identify them. I tried Rules and Alerts but that
responds
to
the sender of the email (the host) not the actual person making the
request
from the web site. Basically a simple email to be sent to an email
address
that will be found in the body is what I want. Can a script be
created
to
do
this, if so how? Any help very much appreciated. Tim



.



Relevant Pages