Collecting Header Info to Send to 3rd Party

I saw a post from 2004 asking for the same thing I need. But it did not receive any responses.

We use a 3rd party email to assist us with filtering out spam. Some emails still do get through occasionally. Users contact us and we tell them to collect the header info by using Fille–>Export, then forward that attachment plus the spam email to our 3rd pary vendor.

I know very little about writing script. But if anyone could offer some assistance, I’d like to create a button. Users will hit this button and it will collect the header info, add it to the spam email as a new memo, and input the address to forward it to.

Thank you very much in advance.

Subject: Collecting Header Info to Send to 3rd Party

Hi,

Maybe here: or here:

http://www-10.lotus.com/ldd/sandbox.nsf/140e61e7f55c607685256ead0064d6c4?OpenForm&ParentUNID=E64037E56A12832D85256D9C0062873D

JYR

Subject: RE: Collecting Header Info to Send to 3rd Party

Jean-Yves,Thank you so much for your response. I am very new to writing script/code. Could you possibly give me more specifics? Such as is that considered a Formula or Lotus Script?

Thanks again,

Melissa

Subject: RE: Collecting Header Info to Send to 3rd Party

For the first one, you can paste the code in an action button. Add a button in your mail file. Add it , for example in the ($ALL) view. This button will act on selected documents.

For the second one, you have to paste the form abd the agent contained in the db. Those elements must be put in your mail file via the Designer.

The new action will be available via the actions menu on selected documents.

JYR

Subject: RE: Collecting Header Info to Send to 3rd Party

First let me say thank you again for assisting me. I appreciate it.

Second, I finally got a chance to play with this. When I try to use the code that was pasted in the first post, I get an error pertaining to this line in the code:

returnpath = getitem(“from”,doc)

The error states:

: Click: 30: Illegal parenthesized reference: GETITEM

What’s the issue? This line looks exactly the same as the others.

Thanks!

Subject: RE: Collecting Header Info to Send to 3rd Party

Sorry

I was too fast

Function GetItem( FieldName As String, doc As NotesDocument) As String

Dim item As NotesItem

Dim cr As String

Dim Contents As String

Dim receivedSplit As Variant

Dim sep As String

cr = Chr(13)+Chr(10)

sep=String(10," ")

While doc.HasItem( FieldName)

	Set item = doc.GetFirstItem( FieldName)

	If Lcase(item.name)="received" Then

		If Instr(item.text,Chr(34)) Then

			tmp=""

			For kk=1 To Len(item.text)

				c=Mid(item.text,kk,1)

				If c=Chr(34) Then c="'"

				tmp=tmp & c

			Next

		Else

			tmp="Received: "+item.text

		End If

		e={@implode(@explode("} & tmp & {";";");@newline)}

		

		receivedSplit = Evaluate(e,doc)

		f={@replacesubstring(@trim("} & receivedSplit(0) & {");@char(9):"} & sep & {";" ")}

		g=Evaluate(f)

		contents=Contents + g(0) + cr

	Else

		Contents = Contents + item.Text

	End If

	Call item.Remove

Wend

GetItem$ = Contents

End Function

JYR

Subject: RE: Collecting Header Info to Send to 3rd Party

Your code is working great! It took me a while to figure this all out being a beginner. But it captures the header info with a pop screen in notepad which is definitely a step in the right direction.If you continue to want to be a big help…Any thoughts on how to now get that to create an attachment, and paste it and the original email into a new memo?

Thanks again for all of your help!

Subject: RE: Collecting Header Info to Send to 3rd Party

in the loop add something similar:

fname is the path of your note pad file.

Call SendFile(doc,fname)
Next jj

Sub SendFile(doc,file)

  Dim session As NotesSession
  Dim Courrier As NotesDocument
  Dim Item As NotesRichTextItem

  Set session = New NotesSession
  Set Courrier      = New NotesDocument (Session.CurrentDatabase)
  Set Item          = New NotesRichTextItem(Courrier , "Body")

  Courrier.SendTo   = "Your Name here"
  Courrier.Form     = "Memo"
  Set object = item.EmbedObject       ( EMBED_ATTACHMENT, "", file)
  Courrier.Subject  = "File SPAM"

  Call Courrier.send(False)

  Exit Sub

End Sub

JYR

Subject: RE: Collecting Header Info to Send to 3rd Party

Jean-Yves,You have been a great help so far, and I truly appreciate your hand-holding and patience. I understand if you want to cut-the-cord at any time…but if not…

I have taken the last bit of code you posted, and tried adding it to the “loop”, but as it is, it won’t allow me to save it. It will only allow me to save it if I change the order - see here:

Sub SendFile(doc,file)

Call SendFile(doc,"c:\temp\notessmtpheader.txt")



Dim session As NotesSession

Dim Courrier As NotesDocument

Dim Item As NotesRichTextItem



Set session = New NotesSession

Set Courrier = New NotesDocument (Session.CurrentDatabase)

Set Item = New NotesRichTextItem(Courrier , "Body")



Courrier.SendTo = "dadministrator@dollartree.com"

Courrier.Form = "Memo"

Set object = item.EmbedObject ( EMBED_ATTACHMENT, "", file)

Courrier.Subject = "File SPAM"



Call Courrier.send(False)



Exit Sub

End Sub

But then it still won’t run. The header doc is created and saved in c:/temp, and it appears up on the screen. I’m not sure if this is the cause of the “create new memo/forward” piece from happening.

Any more help from you would be greatly appreciated. And if not, thanks for everything.

MFK

Subject: RE: Collecting Header Info to Send to 3rd Party

Hi Melissa,

I don’t know what might be the cause but this one is working:

Create an action button in the inbox folder.

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
        Call SendFile(doc,fname)
  Next jj

End Sub

Function GetItem( FieldName As String, doc As NotesDocument) As String
Dim item As NotesItem
Dim cr As String
Dim Contents As String
Dim receivedSplit As Variant
Dim sep As String
cr = Chr(13)+Chr(10)
sep=String(10," “)
While doc.HasItem( FieldName)
Set item = doc.GetFirstItem( FieldName)
If Lcase(item.name)=“received” Then
If Instr(item.text,Chr(34)) Then
tmp=”"
For kk=1 To Len(item.text)
c=Mid(item.text,kk,1)
If c=Chr(34) Then c=“'”
tmp=tmp & c
Next
Else
tmp=“Received: “+item.text
End If
e={@implode(@explode(”} & tmp & {”;“;”);@newline)}

              receivedSplit = Evaluate(e,doc)
              f={@replacesubstring(@trim("} & receivedSplit(0) &

{“);@char(9):”} & sep & {“;” ")}
g=Evaluate(f)
contents=Contents + g(0) + cr
Else
Contents = Contents + item.Text
End If
Call item.Remove
Wend
GetItem$ = Contents
End Function

Sub SendFile(doc,file)

  Dim session As NotesSession
  Dim Courrier As NotesDocument
  Dim Item As NotesRichTextItem

  Set session = New NotesSession
  Set Courrier      = New NotesDocument (Session.CurrentDatabase)
  Set Item          = New NotesRichTextItem(Courrier , "Body")

  Courrier.SendTo   = "Your Name here"
  Courrier.Form     = "Memo"
  Set object = item.EmbedObject       ( EMBED_ATTACHMENT, "", file)
  Courrier.Subject  = "File SPAM"

  Call Courrier.send(False)

  Exit Sub

End Sub

Subject: RE: Collecting Header Info to Send to 3rd Party

I so hate to ask for anymore help on this. You have been really great. And this is just about 100% what we needed. The only thing left for me to ask is that it apparently needs to include the original email as well as the header info when we send it on to our spam vendor. I figured out how to add the message boxes myself at least. =)If you wanted/could tell me what additional code is needed for this.

Thanks again. I really, really appreciate your help and patience.

Subject: RE: Collecting Header Info to Send to 3rd Party

Hi,Send a copy would be a little bit more difficult because you would need to copy the entire content in a new email.

If you forward the mail, you would loose all infos.

I would copy the spam document in a new database (CopyToDatbase), like a cut and paste. I would still send the header infos as attachment.

JYR

Subject: RE: Collecting Header Info to Send to 3rd Party

OK, I’ll see what we can do.I wanted to say thank you for everything. You’ve been a really big help. I truly appreciate it.

Have a good holiday season.