Access or E
New member
- Local time
- Today, 17:52
- Joined
- Aug 29, 2022
- Messages
- 12
Does anyone know how to do this? Whenever I import the email body, it includes the signature, which I don't want. The code using the Word bookmark does not work.
Code:
Dim applOutlook As Outlook.Application
Dim nsOutlook As Outlook.NameSpace
Dim cfOutlook As Outlook.Folder
Dim ifOutlook As Outlook.Folder
Dim AR_Folder As Outlook.Folder
Dim strAR_Body As String
Dim MSG As Outlook.MailItem
'Create a new instance of the Outlook application. Set the Application object as follows:
Set applOutlook = New Outlook.Application
'use the GetNameSpace method to instantiate (ie. create an instance) a NameSpace object variable, to access existing Outlook items. Set the NameSpace object as follows:
Set nsOutlook = applOutlook.GetNamespace("MAPI")
'assign the object variable cfOutlook to the default Contacts folder:
'Set cfOutlook = nsOutlook.GetDefaultFolder(olFolderContacts)
'MsgBox cfOutlook
'assign the object variable ifOutlook to the default Inbox folder:
Set ifOutlook = nsOutlook.GetDefaultFolder(olFolderInbox)
Set AR_Folder = ifOutlook.Folders("AR_Import")
Dim objDoc As Word.Document
Dim objBkm As Word.Bookmark
For Each MSG In AR_Folder.Items
Set objDoc = MSG.GetInspector.WordEditor
Set objBkm = objDoc.Bookmarks("_MailAutoSig")
MSG.BodyFormat = olFormatHTML
MSG.HTMLBody = "<HTML><BODY>" & strBody & "</BODY></HTML>" & MSG.HTMLBody
If Not objBkm Is Nothing Then
objBkm.Select
objDoc.Windows(1).Selection.Delete
End If
Debug.Print MSG.Subject & vbCrLf & vbCrLf
'MSG.Body = Replace(MSG.Body, Signature, "")
MSG.Body = Left(MSG.Body, Len(MSG.Body) - SignatureLength)
Debug.Print MSG.Body
Debug.Print "Email to: " & MSG.To
Debug.Print "Sender: " & MSG.Sender
'Debug.Print MSG.SenderEmailAddress
'Debug.Print MSG.BodyFormat
'Debug.Print MSG.EntryID
'Debug.Print MSG.HTMLBody
Debug.Print MSG.ReceivedTime
'Debug.Print MSG.RTFBody
Next