Solved

Verify Send From address before sending mail in outlook

Posted on 2013-02-04
3
412 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
Comment Utility
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
Comment Utility
That did the trick! Thanks!
0
 

Author Comment

by:imfpalne
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Outlook Free & Paid Tools
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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: …

771 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

10 Experts available now in Live!

Get 1:1 Help Now