Solved

Avoiding insertion of a redundant suffix to recipient's Email

Posted on 2014-02-26
2
382 Views
Last Modified: 2014-02-26
Running Outlook 2007, an Expert has assisted me in coding a script which appends a suffix to the recipient's Email address.  For details, please see http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28374041.html

This works just as I had hoped, but there is a small, unexpected issue.  I have Outlook configured to suspend "sent" messages in the Outbox until a second instance of Send/Receive is executed.  Sometimes I need to review an outbound message, before sending it, and this approach allows me to do that.  If I open a message in the Outbox, make any changes, and then send it, the script appends a second suffix to the recipient's Email address.  If I'm paying attention, of course I will delete the redundant suffix.  However, if there's an easy way to adjust the script so that another suffix won't be added, I'd like to know.
0
Comment
Question by:ddantes
[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 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39889895
That's simple enough.  This should do it.  Replace the code you have now with this version.

Dim bolAddSuffix As Boolean

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkRcp As Outlook.RECIPIENT, olkNew As Outlook.RECIPIENT, intCnt As Integer
    If bolAddSuffix Then
        If Item.Class = olMail Then
            For intCnt = Item.Recipients.Count To 1 Step -1
                Set olkRcp = Item.Recipients.Item(intCnt)
                olkRcp.Resolve
                If InStr(1, LCase(olkRcp.Address), "whoreadme.com") = 0 Then
                    Set olkNew = Session.CreateRecipient(olkRcp.Address & ".whoreadme.com")
                    olkNew.Resolve
                    olkRcp.Delete
                    Item.Recipients.Add olkNew
                End If
            Next
            Item.Recipients.ResolveAll
            Item.Save
        End If
    End If
End Sub

Sub ToggleAddSuffix()
    bolAddSuffix = Not bolAddSuffix
    MsgBox "AddSuffix is now " & IIf(bolAddSuffix, "ON", "OFF"), vbInformation + vbOKOnly, "Toggle Add Suffix"
End Sub

Open in new window

0
 

Author Comment

by:ddantes
ID: 39889941
Perfect.
0

Featured Post

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Find out what you should include to make the best professional email signature for your organization.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

734 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