?
Solved

Modifying the "Content-Transfer-Encoding" header

Posted on 2005-03-28
41
Medium Priority
?
902 Views
Last Modified: 2013-12-18
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.
0
Comment
Question by:RanjeetRain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 12
  • 7
  • +2
41 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13644424
Change to what?
0
 
LVL 14

Expert Comment

by:p_partha
ID: 13644527
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13644590
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Expert Comment

by:p_partha
ID: 13644604
notesmimeheader class

Partha
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13644630
See Working with a MIME entity in LotusScript classes.
0
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13644632
Not available in R5 i guess. Can you check?
0
 
LVL 14

Expert Comment

by:p_partha
ID: 13644642
Ranjeet
am afriad it's only R6

Partha
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13644650
Did you try this, bro, is it possible to create new headers for a new mail??
0
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13644657
I really hope there is a way. Domino shouldn't be outright rude.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 13644683
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13644688
NotesMimeEntity class gives access to the Mime information for read only purpose. Not really possible to modify a header with it.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 13644790
In R5, i believe it's mostly read only .. Nothing much afaik

Partha
0
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13645677
Does anyone know the API that can be used for this. I am sure with Notes API it would be possible.
0
 
LVL 14

Accepted Solution

by:
p_partha earned 252 total points
ID: 13645888
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13646017
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13652324
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13653342
See the Admin Help Db, under Setting Advanced outbound MIME options. Must be all in the Configuration document.
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 248 total points
ID: 13653585
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13653594
Don't forget
    Tell Router Update Config
0
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13660438
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13660780
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
 
LVL 4

Expert Comment

by:bytta
ID: 13660803
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13662469
Thanks for the links bytta. Looks promising. Any idea how to use it?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13662674
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
 
LVL 4

Expert Comment

by:bytta
ID: 13663919
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13664237
But, there is no mail (yet) ...
0
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13670434
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
 
LVL 4

Expert Comment

by:bytta
ID: 13670970
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13671632
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13671665
>> 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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13671710
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
 
LVL 4

Expert Comment

by:bytta
ID: 13672471
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 13673879
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
 
LVL 4

Expert Comment

by:bytta
ID: 13679427
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13679498
Hi guys,

Isn't it time for a truce??

Ranjeet, any progress?
0
 
LVL 4

Expert Comment

by:bytta
ID: 13679975
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
 
LVL 14

Expert Comment

by:p_partha
ID: 13710144
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13975905
Solved??
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16161599
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
 
LVL 19

Author Comment

by:RanjeetRain
ID: 16173054
Sorry guys, been occupied. I don't know what to do with this. Please close as suitable. THanks to all for their time.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question