Link to home
Start Free TrialLog in
Avatar of Corey Gashlin
Corey Gashlin

asked on

Outlook Macro

Hello All,

I am tryign to write a macro for outlook on send out of mail that checks ot see if th recipient is an internal or external. If it is an internal I want it to put it as a delayed delivery and not send until 4PM no matter what day. I have it kinda working just canceling the message if internal.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 Dim recips As Outlook.Recipients
    Dim recip As Outlook.Recipient
    Dim pa As Outlook.PropertyAccessor

    Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
    Set recips = Item.Recipients
    For Each recip In recips
        Set pa = recip.PropertyAccessor
        If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@mycompany.net") > 0 Then
            If MsgBox("Send mail to internal address?", vbYesNo + vbQuestion + 

vbMsgBoxSetForeground, "MY COMPANY E-Mail Policy Notice") = vbNo Then
             Cancel = True
             Call CheckSendTime
             
            
          
             
              
            Else
                Exit Sub
            End If
        End If
    Next
     
End Sub

Open in new window


I tried adding in some subs but it failed saying email already in progress.
ASKER CERTIFIED SOLUTION
Avatar of ltlbearand3
ltlbearand3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.