Get the mail header programmatically

Hi, I would like to create a button in our mail template to report emails as spam. I would like to get the mail header as if I use the View - Show - Page Source menu. Can I do this using LotusScript or formula? I did some research and found a LotusScript method under NotesDocument class called GetMIMEEntity. Am I in the right direction?

Any help/comment/suggestion would be greatly appreciated.

TIA,

Sidi

Subject: some script to get you started,

Main part found somewhere else (OpenNTF?) and developed by a Bernd Szarkowski-Tegtmeier. Any errors created by me :slight_smile:

omitted the declarations, etc

'Get all received fields

Forall receivedtext In doc.GetReceivedItemText( )

strText = strText & "Received: " & receivedtext & Chr(13) & Chr(10)

End Forall

'Now get all fields except body, received, …

Forall itemX In doc.Items

If itemX.name <> “Received” And itemX.Name <> “Body” And itemX.Name <> “Form” And itemX.Name<>“X-MIMETrack” And itemX.Name <>“$UpdatedBy” And itemX.Name <>“$MIMETrack” Then

strText = strText & itemX.name & ": " & itemX.Text & Chr(13) & Chr(10)

End If

End Forall

'at last Body

Set item = Doc.GetFirstItem(“Body”)

If Not item Is Nothing Then

If item.Type = 25 Then

Set mime = doc.GetMIMEEntity

If Not(mime Is Nothing) Then

If mime.ContentType = “multipart” Then

If mime.Preamble = “” Then

p$ = “No preamble”

Else

p$ = mime.Preamble

End If

Set child = mime.GetFirstChildEntity

While Not(child Is Nothing)

Set child = child.GetNextSibling

Wend

Else ’ if not multipart

strText = strText & Chr(13) & Chr(10) & mime.ContentAsText

End If

End If

Else

Set RTItem = doc.GetfirstItem(“Body”)

strText = strText & Chr(13) & Chr(10) & RTitem.text

End If

Else

strText = strText & Chr(13) & Chr(10) & “(no body)”

End If