Modifying the "Content-Transfer-Encoding" header

Hi people,

Can I change the value of a header in a mail I am sending?

I would like to change the Content-Transfer-Encoding header in a text mail that I am sending. How do I go about doing that? If it helps, the code I am using is:


      Dim tmpDoc As NotesDocument
      Set tmpDoc = New NotesDocument(DB)

      With tmpDoc
            .SendTo = ToList
            .CopyTo = CCList
            .BlindCopyTo = BCCList
            .Subject = SubjectText
            .Body = MsgText
            .Send False
      End With


Thanks for your help.
LVL 19
RanjeetRainAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Sjef BosmanGroupware ConsultantCommented:
Change to what?
0
 
p_parthaCommented:
Set header = body.CreateHeader("Content-Type")
  Call header.SetHeaderVal("multipart/mixed")
  REM Create additional headers for mail message
  Set header = body.CreateHeader("Subject")
  Call header.SetHeaderVal("MIME multipart message")
  Set header = body.CreateHeader("To")
  Call header.SetHeaderVal("Roberta Person")
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
RanjeetRainAuthor Commented:
Change to anything you like.

Partha, that looks like should do. But what class those methods are from? body is what, a RTItem object?
0
 
p_parthaCommented:
notesmimeheader class

Partha
0
 
Sjef BosmanGroupware ConsultantCommented:
See Working with a MIME entity in LotusScript classes.
0
 
RanjeetRainAuthor Commented:
Not available in R5 i guess. Can you check?
0
 
p_parthaCommented:
Ranjeet
am afriad it's only R6

Partha
0
 
Sjef BosmanGroupware ConsultantCommented:
Did you try this, bro, is it possible to create new headers for a new mail??
0
 
RanjeetRainAuthor Commented:
I really hope there is a way. Domino shouldn't be outright rude.
0
 
p_parthaCommented:
Sjef,
I worked last week on one mail app, where we read the headerval and marked it as "spam" if there was something in it. So but for ranjeet's requirement, i haven't really given a shot

Partha
0
 
RanjeetRainAuthor Commented:
NotesMimeEntity class gives access to the Mime information for read only purpose. Not really possible to modify a header with it.
0
 
p_parthaCommented:
In R5, i believe it's mostly read only .. Nothing much afaik

Partha
0
 
RanjeetRainAuthor Commented:
Does anyone know the API that can be used for this. I am sure with Notes API it would be possible.
0
 
Sjef BosmanGroupware ConsultantCommented:
It seems that's about a received mail. Ranjeet wants to send a mail with some additional header info. Coming back to my first question: Ranjeet, what do you want to change or add to the header info??
0
 
RanjeetRainAuthor Commented:
That looks relevent Partha. I will go thru it.

SJef, try finding a way to add a header with any value. Say, you want to add a "x-Classification" header with a value "Broadcast".
0
 
Sjef BosmanGroupware ConsultantCommented:
See the Admin Help Db, under Setting Advanced outbound MIME options. Must be all in the Configuration document.
0
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
As it seems, you could add a field (NotesItem) called "Classification", give it a value "Broadcast", and add the fieldname "Classification" to the list of items "Always send the following Notes items in headers" in the Configuration document of your server. At least, that's how I read it. Please, give it a try...
0
 
Sjef BosmanGroupware ConsultantCommented:
Don't forget
    Tell Router Update Config
0
 
RanjeetRainAuthor Commented:
Is there a better way of doing it? I mean a programmatic solution. I wouldn't like any admin activity to be required. Also, will that allow me to modify the value of an existing header? I suppose even if I manage to somehow change it, stmp router will overwrite my changes. I am not really sure how is it gonna work. Let me see the options. It seems, I need to know basically how Domino router tasks adds headers to a mail memo.
0
 
Sjef BosmanGroupware ConsultantCommented:
Look into it, it seems quite straightforward to me. You could at least try to do it this way. It's programmatic, in the sense that you have to add a field to the document with the name Classification. But you always have to tell the router that it should add your field to the header information. That should be done in the Configuration document.

There seems to be no other way to influence the router directly to get the header changed. If you want to play dirty, you could set up an additional SMTP-server that forwards messages from the Domino server to the Internet. This server could modify the header of a message. Yuck.
0
 
byttaCommented:
With Notes API it is possible to create/change any header field (header fields are of Data type=TYPE_RFC822_TEXT).
http://www-12.lotus.com/ldd/doc/tools/c/6.5/api65ref.nsf/852561bd0045e8e785255b3c005a57bb/a4c56487fb6a338185256a2500415baf?OpenDocument&Highlight=2,RFC822

It takes a while to set all the flags correctly so it's no picnic.
0
 
RanjeetRainAuthor Commented:
Thanks for the links bytta. Looks promising. Any idea how to use it?
0
 
Sjef BosmanGroupware ConsultantCommented:
Am I very pessimistic when I say: "Won't work"? It's OUTGOING mail, that still has to pass by the Router. You need to live by the Router's rules.
0
 
byttaCommented:
Sorry - I didn't read your original question...

Even if it shows up in the header part of email programs, Content-Transfer-Encoding is defined in the mime-header for each mime-part of the email - check the source of some emails to get a better idea of it.
http://www-12.lotus.com/ldd/doc/tools/c/6.5/api65ref.nsf/852561bd0045e8e785255b3c005a57bb/0356d2e5e7b906b185256a2500412c55?OpenDocument
- you can send an email with  "Content-Transfer-Encoding=7bit" for the body and a number of attachments with a different encoding for each of them.

It is possible to change the encoding but you are opening a NASTY can of worms... I would not recommend it.

For example, if you want to change the encoding of the body to base64,
What you need to do (assuming you know how to find, allocate, delete, read and write items using the C API):
1: locate the TYPE_MIME_PART containing the body of the email, read MIME_PART struct to mymime (not so easy to do)
2: alloc lots of bytes to write your data to.
3: copy the first "mymime.wBoundaryLen" bytes to the new item without changes
4: read the head (next "mymime.wHeadersLen" bytes), check if it contains a "Content-Transfer-Encoding" part and add/change it - fix length of mymime.wHeadersLen because it's sure to change.
5: read the rest of the data and encode it to base64 - fix length of mymime.wByteCount because it's sure to change.  (not so easy to do)
6: now you know how many bytes you need - alloc a new Item with the correct number of bits and copy your data to it
7: write the new data to the new item (not so easy to do)
8: delete the old TYPE_MIME_PART.
9: Now you must find the MIME_PART_EPILOG for this mime boundary, and realloc it.  This is because the new part (type MIME_PART_BODY) "comes after" the MIME_PART_EPILOG, causing errors (3F:EA) - so this moves the MIME_PART_EPILOG to the back, "fixing" the email...  (not so easy to do)
10 - have a drink, just writing what to do was 3 times more than I expected...

See one of my questions for a bit of info
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21340294.html
It also helps a lot to use the program "nsf_dump" on a small mail.nsf file to see how Lotus chops emails up into items, making them nearly impossble to work with.

So consider yourself warned...
0
 
Sjef BosmanGroupware ConsultantCommented:
But, there is no mail (yet) ...
0
 
RanjeetRainAuthor Commented:
Bytta, you are jumping ahead. My question looks like -- I am composing a mail and I would like to "add some custom headers to it" (seems sjef has a workable solution to it), and I would like to "change the values of certain headers" (this is a mess and router wouldn't really like it).

Looks like this is more of a admin question than a programmatic issue. Not really likable for me.

I am moving on with what I currently have. Will study the domino router and get back. Or can anybody post links about how domino router generates headers for a mail memo?
0
 
byttaCommented:
I know - but 'Content-Transfer-Encoding' is not an email header in the same sense as the 'To', 'From' and 'Subject' (an RFC822 item), it's a part of the mime header.

So changing that one is a bitch using the API - use sjef's idea if you can.
0
 
RanjeetRainAuthor Commented:
bytta, Content-Transfer-Encoding header is required by the transport protocol. See RFC for SMTP for instance. A transport protocol like SMTP needs the data to be in a certain format.  Content-Transfer-Encoding header comes into play wherever some kind of 'non 7-bit ASCII' data is to be sent, including *other* formats.

MIME is to facilitate transportation of ASCII data converted from complex data types (including binary multimedia formats). A MIME part has to has a Content-Transfer-Encoding header because the sending application must tell the transport protocol what what algorithm it used to encode the data and recieving application must know what decoding algorithm to use to convert the stream back into the original piece.

Content-Transfer-Encoding header is not required by RFC 822, but take a look at any modern email client, you will see that it adds a MIME version and a Content-Transfer-Encoding header to the message, even if it contains plain text (no data requiring MIME), or even if it is a completely blank message.
0
 
RanjeetRainAuthor Commented:
>> MIME is to facilitate transportation of ASCII data converted from complex data types (including binary multimedia formats). A MIME part has to has a Content-Transfer-Encoding header because the sending application must tell the transport protocol what what algorithm it used to encode the data and recieving application must know what decoding algorithm to use to convert the stream back into the original piece. <<


MIME is to facilitate transportation of ASCII data converted from complex data types (including binary multimedia formats). A MIME part has to has a Content-Transfer-Encoding header because the sending application must tell the recieving application what what algorithm it used to encode the data and what decoding algorithm it should use to convert the stream back into the original piece.
0
 
RanjeetRainAuthor Commented:
MailAddHeaderItem API function would let me add a header to the mail directly, no admin activity required. http://www-12.lotus.com/ldd/doc/tools/c/6.5/api65ref.nsf/c252131b81cf312a85256567005b4020/85255d56004d3f6385255cf100710a03?OpenDocument If I want to play dirty and use API that is.

Now, I have to sort out influencing the router. Or is it better to chicken out.
0
 
byttaCommented:
I can't use the MailAddxxx in my project - so I had forgotten about it...

But as you claim yourself "A MIME part has to has a Content-Transfer-Encoding header" - it's a MIME header unlike the 'To', 'From' and 'Subject', which are standalone RFC822 headers.
Each mime part is split up into 3 parts, BOUNDARY (a must), HEADER (can be empty), and BODY (can be empty - like if it is a completely blank message).
It's a part of the mime header in 'Body' items of type PART_MIME_TEXT - the email programs parse the body of the email (a MIME item) and display the mime header stuff for it with the real RFC822 type headers.

You should definately compile the nsf_dump program and do a "nsf_dump mail/user.nsf -m -d" and search for Content-Transfer-Encoding to see WHERE it is located - so you really understnd what's going on.
0
 
RanjeetRainAuthor Commented:
I doubt you understand the question. Do you see the question? It is about CONTENT-TRANSFER, adding/manipulating headers and so on. At no point in time I expressed a desire to manipulate MIME. What makes you run behind MIME? I don't really see a point.

Forget MIME, content transfer has to be taken care of even if it is a plain text mail. I know about MIME and other email related concepts much better than you explain. I DONT NEED MIME encoding. It is about manipulating headers. Please stay focused on the topic if you want to be of help.

I would also suggest you to take a look at RFC 1521, specially the sections on MIME-Version Header and Content-Transfer-Encoding Header. The document clearly states -- "If a Content-Transfer-Encoding header field appears as part of a message header, it applies to the entire body of that message.  If a Content-Transfer-Encoding header field appears as part of a body part's headers, it applies only to the body of that body part."

Content-Transfer-Encoding Header can be applied to a mail message. And when applied it has a different meaning than when it is applied to individual content boundaries. Does that make sense to you?
0
 
byttaCommented:
OK - that makes sense...

But I've never seen it implemented in a Lotus Mail database - and I've "dumped" hundreds of emails to a file (it has ALWAYS been a mime header).
0
 
Sjef BosmanGroupware ConsultantCommented:
Hi guys,

Isn't it time for a truce??

Ranjeet, any progress?
0
 
byttaCommented:
Sure... ;o) - sorry for trying to send you on the wrong track...

Let me know if you need help adding it as a standalone RFC822 header manually (not using MailaddHeaderItem() ).
0
 
p_parthaCommented:
Ranjeet
Was going thru some article and got this. Just check whether this is useful

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci1035759,00.html?FromTaxonomy=%2Fpr%2F283841

Partha
0
 
Sjef BosmanGroupware ConsultantCommented:
Solved??
0
 
marilyngCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Split: p_partha {http:#13645888} & sjef_bosman {http:#13653585}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

marilyng
EE Cleanup Volunteer
0
 
RanjeetRainAuthor Commented:
Sorry guys, been occupied. I don't know what to do with this. Please close as suitable. THanks to all for their time.
0
All Courses

From novice to tech pro — start learning today.