Solved

Avoiding insertion of a redundant suffix to recipient's Email

Posted on 2014-02-26
2
367 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Use email signature images to promote corporate certifications and industry awards.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

17 Experts available now in Live!

Get 1:1 Help Now