PDA

View Full Version : Sending email (W2K)



guyver_news
06-06-2002, 04:59 PM
Dear all,

I wish to send an email using scripting, however, my situation is that the script below uses outlook (which is good) but if outlook is configured with multiple profiles, I am unable to send the email.

Is there another way to send email? or how can I overcome this profile issue.

Also, how can I call Outlook express instead of Microsoft outlook?

If you can answer both my questions, thanks in advance.

Kind regards

Paul
=======

Sub Sendemail
Dim WshShell
Dim appOutl
Dim maiMail
Dim recMessage
Dim messsubject
Dim LogTime
Dim LogDate

LogTime = Time
LogDate = Date

Set WSHShell = WScript.CreateObject("WScript.Shell")
Set appOutl = Wscript.CreateObject("Outlook.Application")
' Set a reference to the MailItem object.
Set maiMail = appOutl.CreateItem(0)
' Get an address from the user.
maiMail.Recipients.Add("dude@dude.com")
' Add subject and body text.
messsubject = "DB Backup copy to main server completed at " & " " & LogDate & " " & LogTime
maiMail.Subject = messsubject
maiMail.Body = "See logs for details"

' Send the mail.
maiMail.Send

' Close object references.
Set appOutl = Nothing
Set maiMail = Nothing
Set recMessage = Nothing
End Sub

ywhw
06-26-2002, 02:47 AM
If you want to use Outlook Express vs Outlook both would have to be setup on your computer, with the one you want to use set as your default mail client. If you want Outlook Express you can set that as your default client, and only setup one profile this should work.
But I will warn you in case you don't already know, if you have applied all the security updates to Windows then any script should throw a warning message or two.

guyver_news
06-27-2002, 12:18 PM
Thanks for the Info

darkness
07-05-2002, 07:03 PM
ALSO: Using the smtp mailer built into IIS -

Here is a scriptlet of code you can use with the built-in SMTP mailer in IIS

set mailmsg = createobject("CDONTS.newmail")
mailmsg.from ="Someone@somewhere.com"
mailmsg.TO = "YOURRECIPENT ADDRESS"
mailmsg.Importance = 1
mailmsg.body = "Body text with now function at end" & Now()
mailmsg.Subject = "Subject Line"
mailmsg.AttachFile currentfile 'File Path c:\myfile.txt
mailmsg.send
set mailmsg = nothing

Most people using asp and email tasks perfer this method.

Michael McLaughlin
Systems Mgr.

Michael McLaughlin/images/forums/icons/smile.gif
Systems Manager
Minnesota State University Mankato