By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

send MIME email with HTML and javascript to Outlook

P: 28
Hi All,

I use html to dump some statistics I collect from different servers, and them email this file via SMTP email.

Basically I email html pages with mime type

Expand|Select|Wrap|Line Numbers
  1. Content-Type: text/ html
No I wish to add javascript to these html pages, to make them dynamic and more useful.

I have tried changing mime to
Expand|Select|Wrap|Line Numbers
  1. Content-Type: text/ javascript
  2. Content-Type: text/ javascript1.0
  3. Content-Type: text/ jscript
  4. Content-Type: application/ javascript
but none of these are accepting the javascript code.

Also, setting mime to html display html part of code fine, but simply ignore the javascript code.

Expand|Select|Wrap|Line Numbers
  1. Content-Type: text/ html
  2. Content-Type: text/ html/ javascript [not sure how, but this work same as above LOC]
I have checked on wikipedia that Outlook supports javascipt I am using outlook 2007.

Any help here..?

Thanks and Best Regards,
Aug 8 '11 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 5K+
P: 8,639
that depends upon how you serve the JavaScript.

external file: include as <script type="text/javascript" src="">
internal section: <script type="text/javascript">

it may also depend on whether the UA (user agent => Outlook) supports JavaScript (you checked) and whether the use of JavaScript is enabled.

the MIME type of the HTML has to stay the same (i.e. text/html) since it is not JavaScript. if you reference the scripts correctly, the UA will take care of the script loading itself, just like Websites in a browser.
Aug 8 '11 #2

P: 28
Thanks Dormilich!

I am presently serving the script as internal section only. (though if need be it is also possible for me to put it in separate file).

It is working fine in browsers, but not displaying correctly in Outlook. The contents are being sent as attachment (not email body) as a .js file. I am using SMTP email. Will use some other sort of emailing help (like IMAP or so)?

The scenario is that I will be sending some server stats to a list of people - they all use Outlook. Presently it is plain HTML. Adding javascript is the next step.

Thanks and Best Regards.
Aug 8 '11 #3

Expert Mod 5K+
P: 8,639
IMAP is a protocol to read emails (not send).

I’m not sure if it is possible for Outlook to read JS from attached files (never done it because I hardly send HTML mails). you could try to serve the JS externally (via instead of attaching)
Aug 8 '11 #4

P: 28
Hi Dormilich,

Actually I am not attaching is supposed to something like this. (I have not written the header here ..the content-type and mime headers etc)..let us consider I have to email this html + js code so that it can be read in outlook. Thanks for looking..

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <title>
  4. A web page
  5.     </title>
  6. </head>
  8. <body>
  10. <script language="javascript">
  12. document.write(document.lastModified);
  14. </script>
  16. </body>
  17. </html>
Aug 8 '11 #5

Expert Mod 5K+
P: 8,639
the language attribute is deprecated, use the type attribute instead.
Aug 8 '11 #6

P: 28
Thanks Dormilich..I have tried with that as well already.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  3. </script>
Aug 8 '11 #7

Post your reply

Sign in to post your reply or Sign up for a free account.