Sending MIME mail via C/C++ API

I have a browser based mail app (Non-Domino) that creates HTML email in a browser context.

I then want to send that HTML to a Domino DSAPI filter running in the http process and have that process create a mail message and send it.

I am looking at three approaches:

  1. Place the raw HTML in a Rich Text pass through html CD record. Send message as normal.

However, this will not support embedded images.

  1. Manually create a text/html MIME PART and save it as the “Body” field. Then save the normal and embedded attachments as $File objects and fixup the MIME embedded image references appropriately (e.g., cid:image001.gif@01C55BB0.19CCA1A0).

In other words, try to manually ‘reverse’ the process the router takes in converting incoming MIME mails into a Notes documents.

  1. Since my system already allows me to create a full RAW MIME message. Figure out how to send RAW MIME out directly. Is this possible in the C API?

Any other ideas or approaches to this?? I cannot afford Third Party APIs such as Midas…

Subject: Sending MIME mail via C/C++ API

In the C++ API, look to the LNForm class. There are two functions named:SetStoreAsHTMLAndMIME( LNBOOL flag )

LNBOOL GetStoreAsHTMLAndMIME() const

take a look at those and see if that helps.

SPJ

Subject: RE: Sending MIME mail via C/C++ API

Thanks SPJ,

I have used these functions in the past trying to convert RTF to HTML with some limited success. They would not help me now.

I am trying to store manually created HTML along with BASE64 encoded embedded images into notes so that the router then sends it out as a MIME message.

I am able to create RAW Mime, but it looks like I just can’t put that into a notes doc, but that I would need to store it similar to how the router stores incoming Mime messages. This is not impossible, but I would like to get any other ideas before proceeding.

Thanks

Ken

Subject: Sending MIME mail via C/C++ API

Please guys, I need some feedback on this issue…

Essentially, if I have RAW MIME, is there any easy way to send a MIME email via the C/C++ API?

Subject: RE: Sending MIME mail via C/C++ API

Have you checked mail/sendmail.c and mail/sendmemo (C API)?

You can also add mime parts to an existing email using MIME_PART and NSFItemAppend()

mime-bondary, mime-header and mime-body must all be correct… look 'em up in the API reference (api65ref.nsf).

Subject: RE: Sending MIME mail via C/C++ API

Quick question,

What about handling large, embedded, BASE64 attachments? Aren’t field size limits going to hit here? Do I need to place these in $File objects like the router does to incoming Mime, then fixup the “cd:” references?

If anyone has experience writing large RAW MIME blocks to a Notes Document, please let me know.

Subject: RE: Sending MIME mail via C/C++ API

I haven’t worked much with that don’t know if it’s going to be a problem.I know that the router doesn’t usually place embedded attachments (Content-Disposition: inline;) in $FILE items - only normal ones (Content-Disposition: attachment;)

To test this - I would email myself a HUGE embedded image (to the notes client) and see how the router usually handles this, (do an nsf_dump of your mail.nsf if needed).

Then do as the router does…

Subject: *Follow this advice. This is basically how I learned how to do this.

Subject: RE: *Follow this advice. This is basically how I learned how to do this.

Hi Ben,

I was hoping for some more specific information (code snippets, local knowledge).

Failing that, I will reverse engineer how the router does it but this will be fairly tedious (but not impossible).

You and I did have a conversation regarding this stuff a few months ago. Your suggestions and perspective were very helpful. It’s a shame licensing for Midas was a bit steep for our budget… It would have saved me weeks of effort!

I’ve just finished all of my work on Inbound Mime/RTF conversion it to HTML. Following your earlier suggestion, I used the approach of sending a request to the HTTP server and massaging the response. Works pretty well and I’ve got embedded attachments working nicely as well.

Now for the outbound… I expect this to be much easier.

Subject: You won’t have much trouble

It should be fairly easy. I can’t think of any specific suggestions right now, but to look at the MIME structures from the C API (see mimeods.h) to be sure you understand how they are stored. Even though most of your raw MIME will just be stored, you do have to set up the headers from the info you have. Oh yes, and when you attach files with NSFNoteAttachFile, look up HOST_STREAM, as it will come in handy.

Subject: RE: You won’t have much trouble

Thank you very much. That will help. I’m right into it now and I agree that it shouldn’t be too hard to get done.

I can find HOST_STREAM in the header files, but no information in the docs. It says “Binary Private Stream” in the header. Is this the type I specify when attaching BASE64 encoded objects? Any more info you can give me on this usage?

Subject: RE: You won’t have much trouble

Note to those interested in this thread. The following link provides some excellent background info on what the router does with Mime documents:

http://www-10.lotus.com/ldd/nfr6forum.nsf/0/be76f9e4b4b429d585256b6d006d4974?OpenDocument

Subject: RE: You won’t have much trouble

Glad it worked. I’m working for an company so my stuff is all proprietary (therefore no snippets).

But nsf_dump can be a life saver when you need to see “how Domino does things”, like adding an RFC822 field to emails.

And thanks for the link - wading through 3-4 years of posts looking for relavant stuff is no fun.

Subject: RE: You won’t have much trouble

Will I have any trouble if I write the headers (subject, to, cc etc. as normal text fields and output the body only as MIME?

Subject: I disagree with Ben…

They won’t give you any trouble, but they will not always show up either :wink:

The “To:”, “From:”, “Cc:” etc. fields have a special format in MIME-ified notes, conforming to RFC822 (TYPE_822_TEXT, which are hell to work with).

TYPE_TEXT fields might work fine in Notes, but they will not show up when your mails are transformed to real email.

That is: read externally in mutt/eudora/outlook (accessed using IMAP/POP, sent to non-notes users on the internet, etc).

Hope this makes sense…

Subject: *No, that will be fine. That is how the regular mail works (just converts Body to MIME).

Subject: RE: You won’t have much trouble

Thanks for the advice. Good luck with your product. Perhaps someday, Lotus will offer us a more complete API so things like processing email bodies won’t be so painful!

Subject: RE: You won’t have much trouble

I’m pretty sure that is the correct type to use when using the NSFNoteAttachFile with the base64 encoded image data. I don’t have the code in front of me right now, so I’ll double check, but you should be able to tell by sending a large image through the mail to yourself and comparing the value. I just remember it taking a while to figure out what I was looking for.

Subject: RE: Sending MIME mail via C/C++ API

Thanks for your response.

I suspected that this would be the only approach for me. That said, it shouldn’t be too hard to accomplish since I have the RAW MIME parts already.

I’ll try that and post my results.

If anyone has any other way to do this, let me now.

Ken