Export Email Headers

I’ve been tasked with creating a button in the email memo form that would extract the headers from an email and send them to an address. This is for SPAM control. I’m NOT a programmer and I was curious if anybody knows how to create a button that would do this? Just pointing me in the right direction would be great. I’m hoping somebody has already done this and I could take a peak at their code. Thanks.

Subject: Export Email Headers

SOmething lile that:

Sub Click(Source As Button)

 'testing

Dim s As New notessession

Dim doc As NotesDocument

Dim c As notesdocumentcollection

Dim DeliveryInformation As String

Dim posteddate As NotesDateTime

Dim received As String

Dim mimetrack As String

Dim messageid As String

Dim mailer As String

Dim mimeversion As String

Dim deliveredto As String

Dim cr As String

cr = Chr(13)+Chr(10)

Set db=s.currentdatabase

Set c=db.UnprocessedDocuments



fname="c:\temp\notessmtpheader.txt"



If c.count=0 Then

	Msgbox "Select a document first", MB_OK

	Exit Sub

End If



For jj = 1 To c.Count

	Set doc = c.GetNthDocument( jj )

	

	If doc.HasItem( "Received") Then

		returnpath = getitem("from",doc)

		posted = getitem("posteddate",doc)

		precedence = GetItem("Precedence",doc)

		deliveredto = GetItem("Delivered_To",doc)

		received = GetItem( "Received",doc)

		mimetrack = GetItem( "$MIMETrack", doc)

		messageid = GetItem( "$MessageID", doc)

		mailer = GetItem( "$Mailer", doc)

		mimeversion = GetItem( "MIME_Version", doc)

		body = GetItem("Body",doc)

		subject = GetItem ("Subject",doc)

		

		DeliveryInformation =">From "+returnpath+" "+posted+cr+_

		received+_

		"Subject: "+ subject + cr +_

		"MIME-Track: "+mimetrack +cr+ _

		"Date: " + posted + cr +_

		"Message-ID:" + messageid + cr+"X-Mailer:"+ mailer + cr+_

		"Mime-Version:"+ mimeversion + cr + cr +_

		body

		Open fname For Output As #1

		Print #1, deliveryinformation

		Close #1

		cmd="notepad.exe " & fname

		i%=Shell(cmd, 1)

	End If

Next jj 

End Sub

Subject: RE: Export Email Headers

WOW! Thanks! I’ll set it up today.