The SAS Output Delivery System and reporting techniques

Sending multipart MHTML email from SAS

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Sending multipart MHTML email from SAS

I was given a multipart MHTML document, which I am trying to merge with other data in SAS and send as email through our SMTP server. The MHTML document looks fine when I open it from a browser, but much of it (including embedded PNG graphics) appears incorrect when sent through email. I suspect that the "CONTENT_TYPE" parameter needs to be specified in some other way in my FILENAME statement:

FILENAME sendmail EMAIL

     TO="to address"

     FROM="from address"

     SENDER="sender address"

     SUBJECT="Subject"

     CONTENT_TYPE="text/html";

The header in the MHTML file is as follows:

MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_0003_01CE5175.174C4160"
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.17609

This is a multi-part message in MIME format.

------=_NextPart_000_0003_01CE5175.174C4160

Content-Type: text/html;

charset="utf-8"

Content-Transfer-Encoding: quoted-printable

...

Am I correct in guessing that my problem is the need to define the CONTENT_TYPE differently? If so, is there some way to do so in SAS? I've tried various permutations without success.


Accepted Solutions
Solution
‎06-06-2013 12:13 PM
Occasional Contributor
Posts: 19

Re: Sending multipart MHTML email from SAS

SAS Technical Support was able to send an mht file as an attachment (using the "attach=" option), which isn't the solution I was looking for. Their answer:

We have figured out that sending a message
of this type in the message body is currently not supported in SAS 9.2 or 9.3. We can put a suggestion
in to add support for this in a later release of SAS 9.4 or later.

So currently there is not option for doing this with the email access method.

I'll vote for adding the mht content type to a later SAS release.

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,721

Re: Sending multipart MHTML email from SAS

Hi:

  I really think this is something that you should work with Tech Support. There are email settings that you have to set and I'm not entirely sure I understand how you are "merging" an existing HTML document with "other data" in SAS and then doing an email. So in my opinion, someone needs to take a closer look at the actual files (ALL the files) and the data that's involved.

cynthia

Occasional Contributor
Posts: 19

Re: Sending multipart MHTML email from SAS

The simple example of my SAS program is shown in my initial message. Without being concerned about a merge, the code sends the input file, but the multipart MIME document is not translated properly at the email destination (I have tried different types of recipient).

View the attached file under a browser to see how it should be viewed, then substitute a reference in the "INFILE" statement above.

Attachment
SAS Super FREQ
Posts: 8,721

Re: Sending multipart MHTML email from SAS

Hmmm, well, according to this web site File Extension .MHT Details, the correct MIME type for MHT files is message/rfc822 not text/html

Detailed information for file extension MHT:


Primary association: MHTML Document

Company: Microsoft Corporation

File classification: Archive

Mime type: message/rfc822

But, when I make an MHT file out of Word, for example, and save the file as SAMPLE.MHT the header that is INSIDE the resulting MHT file has something other than message/rfc822 (see attached screen shot).

  I don't understand your original question "Am I correct in guessing that my problem is the need to define the CONTENT_TYPE differently? If so, is there some way to do so in SAS? I've tried various permutations without success." The content-type for the whole e-mail stream is specified in the CONTENT-TYPE= option on the FILENAME statement. But if you are asking how to change the content-type that's INSIDE the MHT file, the only way I can think to do that is to change it by writing a DATA STEP program to alter the CONTENT-TYPE string that in finds inside the file.   I'd still recommend working with Tech Support on this. Seeing the code, ALL the code will make a difference. In your most recent post you suggested to "substitute a reference in the "INFILE" statement above", however you don't show an INFILE statement (that would be INSIDE a DATA step program). You only show a FILENAME statement that establishes a FILEREF named "sendmail". There is a HUGE difference between an INFILE statement that points to a FILEREF and a FILE statement that points to a FILEREF. You never show how you are using the "sendmail" FILEREF in a program. So there is no "substitution" possible without guessing what the rest of your program looks like. And given that INFILE would be READING from your fileref (which seems wonky using the email engine) and FILE would be WRITING to your fileref (which is more normal using the email engine), Tech Support are the folks with the most expertise on the email engine and how to use it and to help figure out whether you are using INFILE when you should be using FILE in the rest of your code.

  cynthia


sample_mht_in_notepad.png
Occasional Contributor
Posts: 19

Re: Sending multipart MHTML email from SAS

With the attachment, I've given all the code. The only items missing are the definitions of our emailsys (SMTP), emailhost, and emailport, which are site-specific (and work very well with text and HTML inputs). I have a more complex version with substitutions, but I got rid of the substitutions for the sake of simplicity. This version would work if, for example, the INFILE statement was referencing a text/html document, but the email result doesn't interpret the HTML part of the input, and reads the PNG sections as straight text. I tried defining TEXT_TYPE=message/rfc822 (thanks for finding this), but the result doesn't vary.

I will try contacting Tech Support.

Super User
Super User
Posts: 6,382

Re: Sending multipart MHTML email from SAS

Did you try running UUENCOD on the file instead of trying to send it as straight attachment?

Occasional Contributor
Posts: 19

Re: Sending multipart MHTML email from SAS

I'm trying to send it as the content of the email, not the attachment. I've provided the simple version above, but I intend to substitute for items in a mail merge if I can get the simple case to work, meaning that I would have to output each email, run UUENCODE, then send.

Thanks, but if I'm unable to resolve I'll reformat the input as HTML (which has some disadvantages) and send that way. So far, I haven't gotten any solution from Tech Support.

Solution
‎06-06-2013 12:13 PM
Occasional Contributor
Posts: 19

Re: Sending multipart MHTML email from SAS

SAS Technical Support was able to send an mht file as an attachment (using the "attach=" option), which isn't the solution I was looking for. Their answer:

We have figured out that sending a message
of this type in the message body is currently not supported in SAS 9.2 or 9.3. We can put a suggestion
in to add support for this in a later release of SAS 9.4 or later.

So currently there is not option for doing this with the email access method.

I'll vote for adding the mht content type to a later SAS release.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 759 views
  • 3 likes
  • 3 in conversation