Copy the code in a notepad file and save the file as “testemail.asp” and put it somewhere in IIS and run from there. Make sure all the three attachments are available before you run this code.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
var theApp //Reference to Outlook.Application
var theMailItem //Outlook.mailItem
//Attach Files to the email
var attach1 = “c:\\temp\\sheet.xls”
var attach2 = “c:\\temp\\mail.doc”
var attach3 = “c:\\temp\\test.txt”
//Construct the Email including To(address),subject,body
//Create a object of Outlook.Application
var theApp = new ActiveXObject(“Outlook.Application”)
var theMailItem = theApp.CreateItem(0) // value 0 = MailItem
//Bind the variables with the email
theMailItem.to = “firstname.lastname@example.org”
theMailItem.Subject = (subject);
theMailItem.Body = (msg);
//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.
alert(“The following may have cause this error: \n”+
“1. The Outlook express 2003 is not installed on the machine.\n”+
“2. The msoutl.olb is not availabe at the location “+
“C:\\Program Files\\Microsoft Office\\OFFICE11\\msoutl.old on client’s machine “+
“due to bad installation of the office 2003.”+
“Re-Install office2003 with default settings.\n”+
“3. The Initialize and Scripts ActiveX controls not marked as safe is not set to enable.”)
document.write(“<a href=\””+”./testemail.asp”+”\””+”>”+”Go Back”+”</a>”)
<meta name=”GENERATOR” content=”Microsoft Visual Studio .NET 7.1″>
<meta name=”CODE_LANGUAGE” content=”Visual Basic .NET 7.1″>
<meta name=”vs_targetSchema” content=”http://schemas.microsoft.com/intellisense/ie5″>
<form id=”Form1″ method=”post” runat=”server”>
<INPUT style=”Z-INDEX: 101; LEFT: 200px; WIDTH: 128px; POSITION: absolute; TOP: 144px; HEIGHT: 32px”
type=”button” value=”Button” onclick=”SendAttach()”>
- Outlook Express 2003 must be installed on the client’s machine with the default settings.
- The “Initialize and Script ActiveX controls not marked as safe” option should be selected as “Enable”.
Open Internet Explorer, go to Tools, Internet Options. Click on the security page and make sure the “Local Intranet” zone is selected at the top. Then click on Custom Level at the bottom. In the following window you will see settings for “Initialize and Script ActiveX controls not marked as safe”, select the option “enable” under the same.
- Here it is assumed that the client will only send emails on local DNS over intranet. If the client needs to send email on a DNS other then the local DNS over Internet then the settings for the Internet Zone must be changed as mentioned in the section 1.2->b of this document.
- Use the system Configuration utility (Msconfig.exe) to examine the services and system startup for third-party applications that might restrict running code in the Office Application.
For example, Outlook Automation applications may fail because you are running an antivirus program that has “script blocker” features.
Alternatively, follow these steps in Outlook to disable third-party add-ins:
|1.||On the Tools menu, click Options.|
|2.||On the Other tab, click Advanced Options.|
|3.||In the Advanced Options dialog box, click Add-In Manager.|
|4.||Click to clear the check box for any third-party add-in.|
If this method resolves the problem, contact the third-party antivirus vendor for more information about an update to the antivirus program.