Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Avoiding insertion of a redundant suffix to recipient's Email

Posted on 2014-02-26
2
Medium Priority
?
390 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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Mailbox Overload?
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

721 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