Need help with Outlook macros - add/remove contact

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
triscom5
Newbie
Posts: 2
Joined: Tue Sep 21, 2010 1:34 pm

Need help with Outlook macros - add/remove contact

Post by triscom5 » Tue Sep 21, 2010 1:40 pm

Hello good people! :)

I need a help from an expert in (outlook) macros writing. What I would like to do is,
exstract some data from a email body and store it into Outlook contacts. See the picture
with proccess flow. All received emails have a standard form for newsletter subscription
and it would look like this:


Email*: [email protected]

Name: Tony Stark

Company: Stark Industries

Action*: Subscribe




So I need a macro that would check the text after "Action*: ", if it is Subscribe or Unsubscribe.

1. If it is Subscribe:

- check if there is already a contact with this email address in Outlook Contacts
> if it is, write message: "Subscriber already exists."
> go to END

- else, generate new contact and copy data from email body to it
> the text after "Name: " goes into Name field
> the text after "Email: " goes into Email field
> the text after "Company: " goes into Company field
> write message: New subscriber %Name% added.
> go to END



2. If it is Unsubscribe:
- check if there is already a contact with this email address in Outlook Contacts
> if it is not, write message: "Subscriber does not exist!"
> go to END
- else, delete the contact
> write message: Subscriber %Name% deleted.
> go to END

Image


Thank you guys for your help!!!

Sergio

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Sep 21, 2010 2:20 pm

Is the incoming email account a POP3 or an IMAP4 type account?

If it is POP3 you can use the RetrievePOP3> command in Macro Scheduler to read and parse the email.

I have also used the COM interface to Outlook inside VBScript code to add contacts, etc.

triscom5
Newbie
Posts: 2
Joined: Tue Sep 21, 2010 1:34 pm

Post by triscom5 » Tue Sep 21, 2010 2:50 pm

Mail server is MS Exchange 2008 and the client (Outlook 2k3/2k7) uses POP3.

The first part of the problem can be fixed with the Rules. So that I can separate the Subscribers from the Unsubscribers.

So I realy need the contact search, add and remove function or the second part of the macro.

Bye.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Sep 21, 2010 2:59 pm

If it were me, I'd write a 100% MacroScheduler solution. Don't use Rules. Rules are (for the most part) client side and only run if Outlook is running. If you want to write VBA code, that is outside the scope of this forum.


I would use Macro Scheduler to read the POP3 mail and parse it.

Then use the following techniques to add or delete the contacts in Outlook.

Programming Outlook with VBScript
http://archive.devx.com/upload/free/bkc ... zzoch6.asp


Once you have some prototype code written, you are welcome to post it for help or comments.

Good Luck!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts