markh1182
05-12-2008, 03:42 AM
Hi, How do I find out the length of characters between 2 points in an email message?
I have the following code that I am trying to amend so it selects the first email in a string of forwarded emails:
Sub PrintOnePage()
Dim mi As MailItem
Dim sBody As String
Dim wdApp As Word.Application
Dim lPos As Long
Const sORIG As String = "-----Original Message-----"
If TypeName(Application.ActiveInspector.CurrentItem) = "MailItem" Then 'only mail
'create a forward to get the header
Set mi = Application.ActiveInspector.CurrentItem.Forward
sBody = mi.Body
lPos = InStr(sBody, "-----Original Message-----")
sBody = Mid(sBody, lPos, 5000)
MsgBox sBody
mi.Close olDiscard 'don't save changes
Set mi = Nothing
End If
End Sub
I am wanting to get the number of characters between the first Original Message and the second Original Message. This is so I can set the length of 5000 to be accurate to the length of the first message in the string of forwards.
Hope this makes sense.
If not let me know and I'll try to be more clear.
Thanks, Mark
I have the following code that I am trying to amend so it selects the first email in a string of forwarded emails:
Sub PrintOnePage()
Dim mi As MailItem
Dim sBody As String
Dim wdApp As Word.Application
Dim lPos As Long
Const sORIG As String = "-----Original Message-----"
If TypeName(Application.ActiveInspector.CurrentItem) = "MailItem" Then 'only mail
'create a forward to get the header
Set mi = Application.ActiveInspector.CurrentItem.Forward
sBody = mi.Body
lPos = InStr(sBody, "-----Original Message-----")
sBody = Mid(sBody, lPos, 5000)
MsgBox sBody
mi.Close olDiscard 'don't save changes
Set mi = Nothing
End If
End Sub
I am wanting to get the number of characters between the first Original Message and the second Original Message. This is so I can set the length of 5000 to be accurate to the length of the first message in the string of forwards.
Hope this makes sense.
If not let me know and I'll try to be more clear.
Thanks, Mark