Solved

Visual Basic for BlueDevilFan

Posted on 2006-07-18
2
394 Views
Last Modified: 2013-11-25
bluedevilfan, you helped me with this post:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21600619.html 

now i need to have the macro look for 2 email aliasaddresses instead of one, ie:

If redMailItem.To = "XXX@XXX.com" Then would be  

If redMailItem.To = "XXX@XXX.com OR BLAH.com" Then


************ORIGINAL MACRO*****************************
'Macro begins here
Public WithEvents myOlItems As Outlook.Items

Private Sub Application_Startup()
    Set myOlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
    Dim redMailItem As Object
    Set redMailItem = CreateObject("Redemption.SafeMailItem")
    redMailItem.Item = Item
    'Change AliasEmailAddress on the following line
    If redMailItem.To = "XXX@XXX.com" Then
        redMailItem.Item = Application.CreateItem(olMailItem)
        'Change the email address on the following line to that of the secretary
        redMailItem.Recipients.Add "XXX@XXX.com"
        redMailItem.Recipients.ResolveAll
        redMailItem.Attachments.Add Item, olEmbeddeditem
        'Change the subject on the following line as desired
        redMailItem.Subject = "FWD Inquiry: " & Item.Subject
        'Change the message body on the following line as desired
        redMailItem.Body = "The message is in the attachment."
        redMailItem.Send
        Item.Delete
    End If
    Set redMailItem = Nothing
End Sub
'Macro Ends Here
0
Comment
Question by:bjv211
2 Comments
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 250 total points
ID: 17133862
In case BDF doesn't see this, try changing:

    If redMailItem.To = "XXX@XXX.com" Then

to:

    If redMailItem.To = "XXX@XXX.com" Or redMailItem.To = "YYY@YYY.com" Then

That should do it...

HTH

J.
0
 
LVL 1

Author Comment

by:bjv211
ID: 17138298
works like a charm :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now