简体   繁体   中英

Creating VB code to extract an email address from the body of a message in Outlook

Let me explain what I need to do:

PROBLEM:

I receive emails for online orders that go into a specific email inbox in Outlook and I would like to send an automatic response to the senders letting them know that their order was received. The issue is this: the senders email is NOT in the from field, it is in the body of the email - the from field is populated with our webadmin address (email orders are generated via an online form from our school website and sent from a centralized account.) As such an automatic rule simply send an email response to the web admin email account and not the actual order.

Email Specifics:

All of these emails have the same subject line. All of the emails with this subject line are filtered into the folder "Online Orders - Incoming" All of the emails are required to have the senders email address in the body; here is an actual email (sensitive information is x'ed out - email address is at the end):

=================================================================

PRINT REQUEST:

Print Job Name : Accounting Majors Department:
AccountNo: xxxx-xxxxxxx-xxxxxx-xxxx FileNo:

Date_In: 08-22-2013

Date_Needed: 08-24-2013

Num_Originals: 2

Num_Copies: 40

Finished_Copy: Front and Back

Paper_Color: Green

Paper_Stock: None

Finished_Size: 8 1/2 x 11

Carbonless_Choice: None

Bindery_Choice: None

Ink Color: Use black ink

Special Instructions:

Thanks, xxxxxx xxxxxx SENDERSREALEMAILADDRESS@xxx.edu

Phone: ext.XXXX Fax: ext. XXXX

======================================================================

I'm very new to VB but I'm capable of learning but I haven't had much luck getting started. What I would like to do is generate an email to the embedded email address in the order form and have the email include a simple message letting our customer know that we have received their order.

If anyone can offer me any help with this I would be very grateful.

Try splitting the email body (on spaces) into an array, and then checking each element of the array for an @ sign and period.
Something like this:

For Each Sec in Strings.Split(Item.Body)
  If Sec.Contains("@") And Sec.Contains(".") Then
    ''At this point, Sec contains the email address. Do something here.

    Exit For
  End If
Next

To get the emails in a custom folder, try this:

Set Items = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Print Center").Items

Or in a custom sub-folder:

Set Items = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Print Center").Folders("Online Oredrs - Incoming").Items

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM