Important alert: (current site time 7/15/2013 11:02:26 PM EDT)
 

VB icon

CDOSYS script

Email
Submitted on: 3/7/2006 12:56:38 PM
By: Dave Vroman 
Level: Beginner
User Rating: Unrated
Compatibility: VbScript (browser/client side)
Views: 13141
author picture
 
     Send eMail Using CDOSYS IMessage Interface.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :CDOSYS script
'**************************************
The original code came from MSDN.
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: CDOSYS script
' Description:Send eMail Using CDOSYS IMessage Interface.
' By: Dave Vroman
'
' Inputs:MailFrom - Format: "Name" <email@address.com>
MailTo - Format: "Name" <email@address.com>; ...
Subject - The Subject Line
Message - Either The Message Or A URL
MsgType - Which Type Of Message String:
"text" - treat the message as pure text
"html" - treat the message as HTML
"url" - execute the url to send the message
'
' Assumes:There are a couple of items that must be filled in for this to work: 
1) smtpserver 
2) smtpserverport
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=9353&lngWId=4'for details.'**************************************

Sub SendMessage(MailFrom, MailTo, Subject, Message, MsgType)
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.
With ObjSendMail.Configuration.Fields
' Send the message using the network (SMTP over the network).
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = portNumber
' Use SSL for the connection (True or False)
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
'.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = MailFrom
'.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = yourpassword
.Update
End With
'End remote SMTP server configuration section==
ObjSendMail.To = MailTo
ObjSendMail.From = MailFrom
ObjSendMail.Subject = Subject
' How The Message Is Sent Is By The MsgType Indicator
Select Case MsgType
Case "text" ' Standard Text Message - No Frills
ObjSendMail.TextBody = Message
Case "html" ' Pre-Format The Message As HTML - Then Use This One
ObjSendMail.HTMLBody = Message
Case "url" ' Use An URL To An ASP Page To Do Your Formatting
ObjSendMail.CreateMHTMLBody (Message)
End Select
ObjSendMail.Send
Set ObjSendMail = Nothing
End Sub


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell 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

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.