?
Solved

Visual Basic for BlueDevilFan

Posted on 2006-07-18
2
Medium Priority
?
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 1000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

762 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