Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- Dim prompt, strMsg, myText As String
- Dim NewMail As MailItem, oInspector As Inspector
- myText = "HERE IS THE TEXT TO BE ADDED"
- 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)), "@nhs.net") = 0 Then
- strMsg = strMsg & " " & pa.GetProperty(PR_SMTP_ADDRESS) & vbNewLine
- End If
- Next
- Set oInspector = Application.ActiveInspector
- If oInspector Is Nothing Then
- MsgBox "No active inspector"
- Else
- Set NewMail = oInspector.CurrentItem
- If NewMail.Sent Then
- MsgBox "This is not an editable email"
- Else
- If oInspector.IsWordMail Then
- Dim oDoc As Object, oWrdApp As Object, oSelection As Object
- Set oDoc = oInspector.WordEditor
- Set oWrdApp = oDoc.Application
- If strMsg = "" Then 'All the recipients are internal to the organisation.
- 'Add contact line to bottom of signature
- oWrdApp.ActiveDocument.Content.InsertAfter myText
- With oWrdApp.ActiveDocument.Content.Paragraphs.Last
- .Range.Font.Bold = True
- .Alignment = wdAlignParagraphCenter
- End With
- End If
- Set oWrdApp = Nothing
- Set oDoc = Nothing
- End If
- End If
- End If
- End Sub
- Dear Somebody,
- Here is the body of my email!
- Kind Regards,
- TM
- Here is my sig
- ** and here is the line added by the VBA **
- Hi Somebody,
- Thanks for your reply. Here's what I think ......
- Good to hear from you,
- TM
- Here is my sig
- _______________________________________________
- From: Somebody
- Sent: Sometime
- Hi TM,
- Here's the reply to your original email!
- Thanks,
- Somebody
- ________________________________________________
- From: TM
- Sent: Initial email
- Dear Somebody,
- Here is the body of my email!
- Kind Regards,
- TM
- Here is my sig
- ** and here is the line added by the VBA **initially** **
- **** This is the line added by the VBA when I reply or fwd ****
- **** It needs to be beneath the signature in the email currently being drafted!!
Add Comment
Please, Sign In to add comment