• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

Visual Basic for BlueDevilFan

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
bjv211
Asked:
bjv211
1 Solution
 
jimbobmcgeeCommented:
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
 
bjv211Author Commented:
works like a charm :)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now