Developing an outlook helper–part 2 from 5–VBA

Series

 

Developing Outlook helper – introduction

Developing Outlook helper-VBA macro

Developing Outlook helper-C#

Developing Outlook helper – javascript for Office 365

Developing Outlook helper – conclusions

Develop like it was ‘9x:

In the early days to develop an outlook addon it was simple : Press ALT+F11 and wrote the VBA. ( in our days , you go to the outlook settings and enable macros)

The code will be something like this:

Public Sub IsUserInEmail()
    Dim current
    Set current = Application.ActiveInspector.CurrentItem
    
    If Not TypeOf current Is MailItem Then Exit Sub
    Dim m As MailItem
    Set m = current
    
    Dim name As String
    name = InputBox("Please give me the user name", "Find User")
    If (Len(name) = 0) Then Exit Sub
    
    
    If (InStr(1, m.To, name, vbTextCompare) > 0) Then
        MsgBox "The name " & name & " has received the email"
        Exit Sub
    End If
    If (InStr(1, m.Sender.name, name, vbTextCompare) > 0) Then
        MsgBox "The name " & name & " has received the email"
        Exit Sub
    End If
    Dim rec As Recipient
    For Each rec In m.Recipients
        If (InStr(1, rec.name, name, vbTextCompare) > 0) Then
            MsgBox "The name " & name & " has received the email"
            Exit Sub
        End If
    Next rec
    MsgBox "The name " & name & " has NOT received the email"
    
End Sub

Test like it was ‘9x:

If you want to test, open the email ( double click the email) . Then run with F5 and debug.

Deploy like it was ‘9x:

Send to the user the VBA script and tell him step by step how to copy / paste