Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Email with CDO

Status
Not open for further replies.
What have you tried so far ?
For me, you have to instantiate at least 2 objects:
Set myMsg = CreateObject("CDO.Message")
Set myConf = CreateObject("CDO.Configuration")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Again, what have you tried so far and where are you stuck in your code ?
Note: Tek-Tips is not an help desk and thus is not supposed to provide ready to play script ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Here is one I create dynamically with another program
to send using OUTLOOK/MAPI with an attachment.
Enjoy.

Dim ToAddress
Dim FromAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment
Dim ol, ns, newMail
ToAddress = "Someone@world.com"
MessageSubject = "Office Stuff"
MessageBody = "Here is your file 12-06-2006"
MessageAttachment = "Y:\folder\subfolder\afile.CSV"
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf
newMail.RecipIents.Add(ToAddress)
newMail.Attachments.Add(MessageAttachment)
newMail.Send


 
Asked and answered many times.

Bart.gif


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Mark is right, this question is posted an EVERY vbscript forum multiple times and there are many, many, examples of how to send email from vbscript.

This is a code snippet that I use to send myself daily security reports from remote servers that work quite well.

I hope you will find it usefull.

Code:
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "myaddress@somewhere.com"
objEmail.To = "myaddress@somewhere.com"
objEmail.Subject = "Secuity Report for " & strServerName 
objEmail.Textbody = "Server Secutirity Report for" & strServerName & vbCRL & strBodyReport
objEmail.AddAttachment = strFilename
objEmail.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
objEmail.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = _
        "10.190.12.128" 'Modify to your SMTP Server Address
objEmail.Configuration.Fields.Item _
    ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
objEmail.Configuration.Fields.Update
objEmail.Send

Thanks

John Fuhrman
Titan Global Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top