send MIME email with HTML and javascript to Outlook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AIProgrammer
    New Member
    • Jul 2008
    • 28

    send MIME email with HTML and javascript to Outlook

    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

    Code:
    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
    Code:
    Content-Type: text/ javascript
    Content-Type: text/ javascript1.0
    Content-Type: text/ jscript
    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.

    Code:
    Content-Type: text/ html
    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,
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that depends upon how you serve the JavaScript.

    external file: include as <script type="text/javascript" src="http://example.org/myfile.js">
    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.

    Comment

    • AIProgrammer
      New Member
      • Jul 2008
      • 28

      #3
      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.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        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 http://example.org/myfile.js instead of attaching)

        Comment

        • AIProgrammer
          New Member
          • Jul 2008
          • 28

          #5
          Hi Dormilich,

          Actually I am not attaching them..it 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..

          Code:
          <html>
          <head>
          	<title>
          A web page
          	</title>
          </head>
          
          <body>
          
          <script language="javascript">
          
          document.write(document.lastModified);
          
          </script>
          
          </body>
          </html>

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            the language attribute is deprecated, use the type attribute instead.

            Comment

            • AIProgrammer
              New Member
              • Jul 2008
              • 28

              #7
              Thanks Dormilich..I have tried with that as well already.

              Code:
              <script type="text/javascript">
              
              </script>

              Comment

              Working...