Solved

Avoiding insertion of a redundant suffix to recipient's Email

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

740 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