Wednesday 24 September 2014

Set Outlook email subject as required field


Open Outlook
Press Alt+F11, it will give you visual Basic editor.
Press Ctrl+R which in turn open Project-Project 1
On the Left Pane, one can see "Microsoft Outlook Objects" or "Project1", expand this. Now one can see the "ThisOutLookSession".
Double click on "ThisOutLookSession".It will open a Code pane.
Copy and Paste the following code in the right pane and save it.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(Trim(strSubject)) = 0 Then
Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject")
= vbNo Then
Cancel = True
End If
End If
End Sub

Now whenever you try to send a mail without subject, it would raise a pop-up to remind you.