Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Attachment using Javascript for Microsoft Outlook How?

    Hello Javascript Developers

    I want to send a file attachment (notepad textdocument) throughMicrosoft outlook using javascript ,How can I do that.
    can any one suggest it is helpful


    Thanks and regards
    Murali

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    http://blogs.msdn.com/b/rajnishkaush...tion-2007.aspx

    But I warn you that this will work in IE only AND the user needs to have Outlook client installed AND the user has to allow ActiveX control to run on the page. Otherwise, this is useless.

    This type of script is frowned upon for security reasons. It may be acceptable in a controlled environment (e.g. Intranet)

  • #3
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, Thanks for reply


    I want to send an attachment for chrome,firefox,and safari what can you suggest me please.

    Thanks and regards
    Murali

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,023
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    You will need to do this with server-side code, then. PHP/ASP/JSP/ASP.NET.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    I want to attach a file using javascript using outlook 2010 How can I do that programatically ? is it possible with client side please suggest

    Thanks and regards
    Murali

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Quote Originally Posted by jscriptuser View Post
    Hi,

    I want to attach a file using javascript using outlook 2010 How can I do that programatically ? is it possible with client side please suggest

    Thanks and regards
    Murali
    You have already been given the answer in post #4. Was that not clear in some way?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Philip,

    I gone through that post ,but from client side I noticed that they provided mailitem.attachments.add() method is available in jscript, I hope this might allow files to be attached .can you figure out this code. I tried but got an error the "This file is invalid error.

    var theApp = new ActiveXObject("Outlook.Application")
    var theMailItem = theApp.CreateItem(0) // value 0 = MailItem
    //Bind the variables with the email
    theMailItem.to = to
    theMailItem.Subject = (subject);
    theMailItem.Body = (msg);
    theMailItem.Attachments.Add("Test.rtf");
    //Show the mail before sending for review purpose
    //You can directly use the theMailItem.send() function
    //if you do not want to show the message.
    theMailItem.display();
    theMailItem.send();

    Thanks and regards
    Murali

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    As I said, you can only make that work in IE in conditions I described. Other browsers will not allow you to do that.

  • #9
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi ,

    I have got error at following point .while attachments

    var textfilename="c:\test.txt";
    email.Attachments.Add(textfilename);

    I am getting the error :cannot find this file. verify the path and filename are correct i am using outlook 2010. what needs to be corrected in the code.


    Thanks
    Murali

  • #10
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,273
    Thanks
    10
    Thanked 581 Times in 562 Posts
    maybe, the filename should be escaped like this:

    Code:
    var textfilename="c:\\test.txt";
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •