Solved

Verify Send From address before sending mail in outlook

Posted on 2013-02-04
3
419 Views
Last Modified: 2013-02-06
Hi,

I'm new to VBA in Outlook, but have created this little script that pops up a confirmation box that asks if the user have remembered to choose the right "Send from" address.

However I'd like to have it do that - only - if a particular send from address has been selected - how can I do that?

Here's the script so far:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    Dim intRes As Integer
    Dim strMsg As String
    strMsg = "Har du husket den rigtige ""From"" adresse? "
    intRes = MsgBox(strMsg, vbYesNo + vbDefaultButton1, "HUSK! ")
    If intRes = vbNo Then
    Cancel = True
    End If

End Sub
0
Comment
Question by:imfpalne
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 38851635
Try this.
OM Gang

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    Dim intRes As Integer
    Dim strMsg As String, strSender As String

    strSender = Item.SendUsingAccount.SmtpAddress
        'test from address
    If strSender = "theparticularaddress@mydomain.com" Then

        strMsg = "Har du husket den rigtige ""From"" adresse? "
        intRes = MsgBox(strMsg, vbYesNo + vbDefaultButton1, "HUSK! ")
        If intRes = vbNo Then
            Cancel = True
        End If
    End If

End Sub
0
 

Author Closing Comment

by:imfpalne
ID: 38858633
That did the trick! Thanks!
0
 

Author Comment

by:imfpalne
ID: 38858826
Hi OM gang,

You'r solution worked for my account, but apparently not for my colleague - I've created a new question here if you could take a look at it?

http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_28021804.html
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

Suggested Solutions

If you don't know how to downgrade, my instructions below should be helpful.
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 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…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

828 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