PermaLinkAnyone know how to add custom X header to outgoing Domino email
posted Friday 14th, May 2004
 



A gent with whom I used to work emailed another former cohort and me with this request:
Either of you smart boys know how to add a custom X header to an e-mail sent from a Domino client? I want to add a header as a flag for a third party SMTP relay to recognize and process.

I am useless on my own :-) ...so anyone have the answer?
Comments :
 
 

1. Posted by Josh Humphrey09/09/2007 08:42 PM



this is slightly modified from the Help, only works in ND6 or greater... the X header is called X-The-Dude

Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim body As NotesMIMEEntity
Dim header As NotesMIMEHeader
Dim child As NotesMIMEEntity
Dim stream As NotesStream
Set db = s.CurrentDatabase
s.ConvertMIME = False ' Retain MIME format
Set doc = db.CreateDocument
REM Create parent entity
Set body = doc.CreateMIMEEntity
Set header = body.CreateHeader("Content-Type")
Call header.SetHeaderVal("multipart/mixed")
Set header = body.CreateHeader("Subject")
Call header.SetHeaderVal("MIME multipart message")
Set header = body.CreateHeader("To")
Call header.SetHeaderVal("""Charlie Brown"" <c.brown@peanuts.com>")
Set header = body.CreateHeader("X-The-Dude")
Call header.SetHeaderVal("Donny, these men are nihilists. There's nothing to be afraid of.")
Set stream = s.CreateStream
REM Create first child entity
Set child = body.CreateChildEntity
Call stream.WriteText("Text of message for child 1." _
& Chr(10) & Chr(10))
Call child.SetContentFromText(stream, "text/plain", _
ENC_QUOTED_PRINTABLE)
Call stream.Truncate
REM Create second child entity
Set child = body.CreateChildEntity
Call stream.WriteText("Text of message for child 2.")
Call child.SetContentFromText(stream, "text/plain", _
ENC_QUOTED_PRINTABLE)
Call doc.send(False)
s.ConvertMIME = True ' Restore conversion




2. Posted by Joe Litton - website09/09/2007 08:42 PM



Josh, you ROCK! Your next La Ideal lunch is on me




3. Posted by Stephan H. Wissel - website09/09/2007 08:42 PM



Hi Rock, hi Josh,
the solution is quite compelling. However if the task is to flag ALL outgoing mail you need to come up with something else/additional. We're using Group Anti-Virus and they provide a hook to apply code to all messages in the mail.box of the server. There you can easily add X-the-dude . The only change to the code: get the existing header instead of creating new mime. Again: ND6 required
stw