Problem creating an email with an attachment in Javascript

前端 未结 3 382
遇见更好的自我
遇见更好的自我 2021-01-03 07:33

I\'m initiating an email create, by calling the code below, and adding an attachment to it.

I want the user to be able to type in the receipient, and modify the cont

相关标签:
3条回答
  • 2021-01-03 08:03

    first do mItm.display() then write mItm.GetInspector.WindowState = 2; this will work

    0 讨论(0)
  • 2021-01-03 08:18

    Won't work outside of IE, the user needs to have Outlook on the machine and an account configured on it. Are you sure you want to send an email this way?

    0 讨论(0)
  • 2021-01-03 08:21

    I'm trying it with this little snippet, and it works flawlessly:

    var objO = new ActiveXObject('Outlook.Application');
    var mItm = objO.CreateItem(0);
    
    var mAts   = mItm.Attachments;
    var p_file = [
      "http://stackoverflow.com/content/img/vote-arrow-up.png",
      "http://stackoverflow.com/content/img/vote-arrow-down.png"
    ];
    for (var i = 0; i < p_file.length; i++) {
      mAts.add(p_file[i]);
    }
    

    Note that I left off all optional arguments to Attachments.Add(). The method defaults to adding the attachments at the end, which is what you seem to want anyway.

    Can you try this standalone snippet? If it works for you, please do a step-by-step reduction of your code towards this absolute minimum, and you will find what causes the error.

    0 讨论(0)
提交回复
热议问题