All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
allows,fill,send,Outlook,message,from,script,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,486. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Click here to see a screenshot of this code!Mess Officer Management System (Sistem Pengurusan Mess Pegawai)
By Mohd Fauzi on 11/23

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Send Outlook message from script

Print
Email
 
VB icon
Submitted on: 2/3/2001 12:27:13 AM
By: T Runstein 
Level: Beginner
User Rating: By 15 Users
Compatibility:ASP (Active Server Pages), VbScript (browser/client side)

Users have accessed this code 75828 times.
 
(About the author)
 
     This allows you to fill out and send an Outlook message from script. Uncomment 2 lines to create a sub that can be included in a larger script. Great for admins who routinely send reports. 'T Runstein
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Send Outlook message from script
    '     
    ' Description:This allows you to fill ou
    '     t and send an Outlook message from scrip
    '     t. Uncomment 2 lines to create a sub tha
    '     t can be included in a larger script. Gr
    '     eat for admins who routinely send report
    '     s. 'T Runstein
    ' By: T Runstein
    '
    ' Inputs:The script, as shown, is all ha
    '     rdcoded, but you could easily call "inpu
    '     tbox", or read inputs off a form to fill
    '     in the items. If you need help adapting 
    '     this to your needs, let me know - I'm ha
    '     ppy to help you customize it.
    '
    ' Returns:You can choose to preview by u
    '     sing the .display, or send without previ
    '     ew by using .send
    '
    ' Assumes:As with all .vbs scripts, you 
    '     must have the scripting runtime. You als
    '     o need Outlook installed.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6480&lngWId=4    'for details.    '**************************************
    
    'Uncomment the sub and 
    'end sub lines to use this in a program.
    '     
    'Leaving these commented will allow you 
    '     
    'to run this as a standalone script
    'sub SendAttach() 
    'Open mail, adress, attach report
    Dim objOutlk	'Outlook
    Dim objMail	'Email item
    Dim strMsg
    Const olMailItem = 0
    'Create a new message
    	Set objOutlk = createobject("Outlook.Application")
    	Set objMail = objOutlk.createitem(olMailItem)
    	objMail.To = "t_a_r@email.msn.com"
    	objMail.cc = "" 'Enter an address here To include a carbon copy; bcc is For blind carbon copy's
    'Set up Subject Line
    	objMail.subject = "I saw your code On Planet Source Code on " & cstr(month(now)) & "/" & cstr(day(now)) & "/" & cstr(year(now))
    'Add the body
    	
    	strMsg = "Your code rocks!" & vbcrlf
    	strMsg = strMsg & "I voted and gave you an excellent rating!"
    'To add an attachment, use:
    	'objMail.attachments.add("C:\MyAttachmentFile.txt")
    	objMail.body = strMsg
    	objMail.display 'Use this To display before sending, otherwise call objMail.Send to send without reviewing
    'Clean up
    Set objMail = nothing
    Set objOutlk = nothing
    'end sub


Other 2 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/16/2001 4:03:00 AMJos Krause

When I run your script I got an error stating I was using an invalid calling method to the CreateObject. I got rid of that error by using: Server.CreateObject (but I guess this beats the point to your script) Anyway I recieve this error as a follow up:

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.

Hope you can help out. I think it's too bad that most code that is posted is not testen on other computers cause this is about the 24th time I mailed an author telling them the code doesn't work on my PC which is a shame. But no offense really just a general thought.

All the best,

Jos.
(If this comment was disrespectful, please report it.)

 
2/16/2001 8:48:44 AMWesley

Yeah, well I think this code is really good...besides..it's in the beginner category. Keep up the good work, I'll really enjoy your code :)
(If this comment was disrespectful, please report it.)

 
2/16/2001 12:01:25 PMChiefDND

I get the following error:

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'Outlook.Application'

Found Q194801 at http://support.microsoft.com
(If this comment was disrespectful, please report it.)

 
2/16/2001 7:15:38 PMT Runstein

Thank you all for your feedback! Jos, you are right, much of the code here isn't tested on enough machines (I wish I had access to more platforms).

I probably should have clarified that this script was created for a Windows Script Host application (part of a larger script that generates a report and emails it out). However, it should work in ASP.

"Server." does need to be added for ASP as you've already discovered. As far as the remaining error, sounds like Outlook is not registered on your web server (or something is spelled incorrectly).

On more point: If you run this in ASP, use the .send, not the .display method - you won't want pending outgoing messages stacking up on your web server.

Let me know if you have any other questions or if you're still having trouble getting this to work.
(If this comment was disrespectful, please report it.)

 
4/24/2001 7:50:14 AMBrandon

I am having the following error when running the above code:
(If this comment was disrespectful, please report it.)

 
5/15/2001 2:08:47 PMAndrew

I got the error:
(If this comment was disrespectful, please report it.)

 
5/15/2001 2:09:48 PMAndrew

I get this error. Please e-mail me and tell me how to fix it. I am using an ASP page in Visual Interdev.

activex component can't create object 'outlook.application'
(If this comment was disrespectful, please report it.)

 
5/15/2001 2:17:03 PMAndrew

FIXED IT!
Problem: ActiveX component can't create object 'outlook.application'
Fix: Change your Internet Explorer security settings.

Click Tools|Internet Options and then Security. Click the Internet zone and then click the Custom Level button. Select Prompt for the Initialize and script ActiveX Controls setting. Click OK. You will be prompted just before Microsoft Outlook initializes.


(If this comment was disrespectful, please report it.)

 
11/16/2001 3:50:58 PMFred

In order to use this code, does the MS-Outlook 9.0 object library reference compatible with Outlook 2000.
if yes, then I am still getting the error:
ActiveX component
can't create object
'outlook.application'

By the way, I already set the Internet Option security according to what has been suggested in the Discussions above.
I am developing ASP in Visual Interdev
(If this comment was disrespectful, please report it.)

 
11/23/2001 11:42:26 PMmanoj

how to register on the web server..?pls suggest i could not find the the name of dll used could u give me the name of dll to register?
(If this comment was disrespectful, please report it.)

 
11/26/2001 8:40:46 AMT Runstein

Outlook 2000 should work with this code. msoutl9.dll must be registered on the server.
Since I wrote this code awhile back, I think it's time to update it! I will put together a new submission to send email without using Outlook later this week.
(If this comment was disrespectful, please report it.)

 
2/14/2002 3:40:38 PMBen

I've tried and tried to get this to work but with no success. I then toot he code and placed into a wsh script and ran it from a command prompt and it worked fine, so code itself works. I don't get any errors about not being able to create the outlook object but that's where the script is getting hung! I've even tried to call a wsh script inside an asp page, and that doesn't work. That actually doesn't even error out. Any help would be really helpful. Thanks.
(If this comment was disrespectful, please report it.)

 
10/14/2002 4:43:13 PM

I too am having problems getting this to work. I would love to have an example that has been tested as an asp page, that works. This page doesnt error out, it simply times out. Dll is registered, I changed to server.createobject...to no avail. Please help. Cannot seem to find this anywhere.
(If this comment was disrespectful, please report it.)

 
11/10/2002 5:35:27 PM

Thank you very much for your help by posting this code. Would you be able to advise me how to register the dll on my server.

Thanks
(If this comment was disrespectful, please report it.)

 
12/10/2002 3:01:44 PM

This works great. Do you know how to caputre the events associated with the email form. For example, I want to capture the "Send" event so I can write out to a DB saying when the user sent out the email.
(If this comment was disrespectful, please report it.)

 
2/14/2003 7:02:32 AM

Hello,

can somebody tell me how to define the email account from which the message will be sent?
Thanks
(If this comment was disrespectful, please report it.)

 
3/13/2003 3:19:27 PM

Where can I get the msoutl9.dll? I can't find it anywhere. Not on my PC (where I have outlook 2000 installed). Nor on MSDN, or searches. Hesitant to install full outlook 2K program on server that is also running OWA.

(If this comment was disrespectful, please report it.)

 
4/24/2003 12:06:35 PM

It's not working for me also from
an ASP.
I even tried to activate it from a VB dll and got the
(If this comment was disrespectful, please report it.)

 
7/9/2003 12:27:14 PM

does anyone make it work for asp.net? thanks a lot
(If this comment was disrespectful, please report it.)

 
8/26/2003 5:54:33 AM

Got the same error:

Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'Outlook.Application'


(If this comment was disrespectful, please report it.)

 
10/8/2003 4:14:55 AM

Thanx for the code, it works great.
Only one problem. Whenever the code runs, i get a prompt saying that the activeX control mught be unsafe to interact with other parts of the form, is there a way to get rid of this prompt. I tried the security settings but i just can't get it right
(If this comment was disrespectful, please report it.)

 
2/18/2004 6:36:01 PM

Ive used this script, now i want to use another script to call the message that was created. Is there a way to maybe instead of puting objOutlk.createitem(olMailItem) having it open the existing email thats allready open in the background. Ive tried deleating this statement but it gives an error. please help, thank you
(If this comment was disrespectful, please report it.)

 
7/5/2004 11:44:13 PM

I tried this code but I got the error below:
Microsoft VBScript runtime (0x800A01AD)ActiveX component can't create object: 'Outlook.Application'

I tried to change at Internet Explorer security setting but the error still occur. Pls help me. I really need this urgently.

(If this comment was disrespectful, please report it.)

 
7/27/2004 6:45:04 AM

I am having problems getting this
to work. when I run the script in interdev ( after ading the reference dll )it doesnt
error out, it simply times out. Dll is registered. When I run the code in VB ( after doing the necesssary ammendmnts to the code above) it works perfectly and I could send the mail. Pls explain why it gives timeout error in ASP. I appriciate if you can send me a worked out example project.

Regards
Vimuks
(If this comment was disrespectful, please report it.)

 
1/2/2005 10:09:37 PM

ActiveX component can't create object: 'CDONTS.NewMail'

(If this comment was disrespectful, please report it.)

 
1/2/2005 10:10:55 PM

ActiveX component can't create object: 'CDONTS.NewMail'
what's this error all about? help.. thanks.. cute_leny at yahoo
(If this comment was disrespectful, please report it.)

 
2/1/2006 7:11:16 PMnikoo

This is very good code and it works if you pase it in the vbscript page in visual studio not in asp page,
I have a question from author; if I want reverse of this function, send email to script how I can write it?
I really appreciate it if you help me thank,

(If this comment was disrespectful, please report it.)

 
1/16/2007 1:56:32 PMdjones

I think this code works pretty well. The only issue i have encountered with it is that when i run the script, i get a message from Microsoft Outlook:

A Program is trying to automatically send e-mail on your behalf. Do you want to allow this?
If this is unexpected, it may be a virus and you should choose "No".

When i select Yes, the file continues to run successfully. I am sure this is a security setting, but i cannot figure out which one it is. Please Help!
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.