Consulting

Results 1 to 10 of 10

Thread: Outlook Solution Wanted

  1. #1
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location

    Outlook Solution Wanted

    Hi

    Upon pressing the SEND button, in case a specific email is not present in the TO field and base on the subject line of the email,I would like to be alerted by a window similar to the one that pops up on the screen when the user mentions attachement in the body of the email, but forgets to add it.

    Unfortunately Outlook does not provide a rule that can be set for that purpose.

    Can someone be so kind to post a VBA module or another solution for this issue?

    Thank you in advace for your help.

  2. #2
    You will have to explain "in case a specific email is not present in the TO field and base on the subject line of the email"
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location
    The process:

    1. You compose the email
    2. Subject line will always start with Sales Order
    3. Press Send
    4. If user forgets to add a specific email in the TO field, say "example at example.com", a window warning pops up telling the user that the example at example.com email is missing.

    Help, please.
    Last edited by Castiel; 11-25-2016 at 05:29 AM.

  4. #4
    OK, the fog is clearing. If you press Send and there is no recipient you will always get a warning. You can't send a message without a recipient.
    Do I take it that when you have Sales Order in the Subject that you wish to check the recipients to ensure that an e-mail address is included among those recipients? In that case, put the following in the ThisOutlookSession module.
    Option Explicit
    
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    'Graham Mayor - http://www.gmayor.com - Last updated - 25/11/2016
    Dim oRecipient As Recipient
    Dim bName As Boolean
    Const strAddress As String = "someone@somewhere.com" 'The address you wish to check
        If InStr(1, Item.subject, "Sales Order") = 1 Then
            For Each oRecipient In Item.Recipients
                If oRecipient.Address = strAddress Then
                    bName = True
                    Exit For
                End If
            Next oRecipient
            If bName = False Then
                If MsgBox("The recipient '" & strAddress & "' is missing from the message." & vbCr & _
                          "Do you wish to send the message?", vbYesNo) = vbNo Then Cancel = True
                'or just add the address e.g.
                'Item.Recipients.Add(strAddress).Type = 2 'as CC (1 for To, 3 for BCC)
                'Item.Recipients.ResolveAll
            End If
        End If
    lbl_Exit:
        Set oRecipient = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  5. #5
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location
    Hi

    Capture.JPG

    Thank you for your reply and efforts.
    I inserted that module as instructed - I suppose I did - but nothing happens when I send the emails.
    I am using Outlook 2016.
    I pressed Alt + F11 to open the Microsoft Visual Basic for Applications - VbaProject.OTM, doubled click ThisOutlookSession and pasted the code, pressed save, closed that window, and back to Outlook.
    Then I composed and sent a message to test the code, nothing happens. I may be doing something wrong...

  6. #6
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location
    Hi
    Sorry... it is actualy working...
    Just some more details on that issue...
    I should have mentioned that Outlook is being used by Quickbooks to send the Sales Orders.
    The code does work as is. However, when I tested it by sending a Sales Order from Quickbooks, it does not work.
    Also, the subject line starts with Sales Order, but it is actualy something like Sales Order SO10949 from [company name]. And that S010949 is the sales order number, which changes for every new sales order.

  7. #7
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location
    Also, the reason I need this reminder is because I do not email the sales order to the customer.
    So, when I press email sales order from withing Quickbooks, Outlook picks up the default customer email, and not the one I usually use to email the sales orders.
    I can't change that email, because I need it there to email other documents to our customers like their invoices, etc. Otherwise, I could just put down the email I usually use to email the sales orders... see my predictament?

  8. #8
    I regret I know nothing about Quickbooks or how it interfaces with Outlook.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  9. #9
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location
    The relationship between Quickbooks and Outlook is this: Quickbooks uses Outlook as the default email client.

  10. #10
    VBAX Regular
    Joined
    Nov 2016
    Posts
    7
    Location
    Quote Originally Posted by gmayor View Post
    I regret I know nothing about Quickbooks or how it interfaces with Outlook.
    Can this code be modified in order to be trigger the pop up warning windows if the following words are found in the body of the email?

    cat:masterlink
    cat:md
    cat:lg
    cat:hja

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •