Open OUTLOOK without an especific "to:" adress and a HTML code in the body. Javascript or ASP.NET

Posted on 2008-11-05
Last Modified: 2012-06-27
I want to send a mail with a HTML code to any of my outlook contacts (groups) from a (vbscript) - javascript application. I don't care if the HTML is in the body or attached.
I used CDONTS but the problem is that i can't choose my outlook contacts.
I try but the problem here is that i can't send a long HTML code string, querystring limit.
Please !!! I need help !!!
Question by:antonio1313
    LVL 11

    Assisted Solution

    Accessing a client's outlook data from a web page is something that would probably never work well.
    1 Any browser would prevent you from running activex unless explicit permission is granted (In IE's , Internet Options , go to the Security tab -> from Custom Level go to Initialize and script ActiveX controls not marked as safe for scripting and select Prompt)
    2 Outlook will try and prevent external objects to get access to it's data.
    3 Not all clients use outlook
    The list goes on...

    var Const_olFolderContacts = 10;
    var objApp = new ActiveXObject(Outlook.Application);
    var objNS = objApp.GetNamespace(MAPI);
    var colContacts = objNS.GetDefaultFolder(Const_olFolderContacts).Items
    for( var i=1; i<=colContacts.count;i++)
     var v = colContacts.item(i);
     alert(v["FullName"]+ (+v["Email1Address"]+));

    Open in new window

    LVL 1

    Accepted Solution

    Great !! I know this is not the right way ... but it's the client way.
    Thank u !!
    I don't use exactly what you say but you help me to find the solution. The code I post is what I used. With this code I don't need to select "Prompt" ... only "Ask" in the IE configuration.

    function openMail() {
    	try {
    		var objApp = new ActiveXObject("Outlook.Application");
    		var objNS = objApp.GetNamespace("MAPI");
    		var theMailItem = objApp.CreateItem(0) 
    		theMailItem.Subject = ('<%= subject %>');
    		theMailItem.HTMLBody = ('<%= strHTML %>');
    	catch(e) {
    		alert("An error message")

    Open in new window


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now