Solved

Visual Basic for BlueDevilFan

Posted on 2006-07-18
2
390 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

747 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

16 Experts available now in Live!

Get 1:1 Help Now