VBA macro Outlook - accepting every attachment before sending message

xxtomsonxx 21 Reputation points
2021-10-21T10:53:48.617+00:00

Hello,

Is it possible to check by macro in Oulootk if email contains any attachment, and if so, prompt for accept or deny attachment before sending the message ?
The same for all "send to" addresses. Before sending the email, prompt for every address for accepting?

Thx in advance!

Outlook Windows Classic Outlook for Windows For business
Developer technologies Visual Basic for Applications
0 comments No comments
{count} votes

Accepted answer
  1. kinuasa 371 Reputation points
    2021-10-25T01:07:05.403+00:00

    Hi,
    I recommend to use the (Application).ItemSend event.

    'ThisOutlookSession  
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)  
      Dim msg As String  
      Dim att As Outlook.Attachment  
        
      If TypeOf Item Is Outlook.MailItem Then  
        If Item.Attachments.Count > 0 Then  
          msg = "This message contains the following attachments." & vbNewLine & _  
                "Do you want to send it as it is?" & vbNewLine  
          For Each att In Item.Attachments  
            msg = msg & vbNewLine & "* " & att.FileName  
          Next  
          If MsgBox(msg, vbQuestion + vbSystemModal + vbYesNo) = vbNo Then Cancel = True  
        End If  
      End If  
    End Sub  
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.