Mark,
On #2:  If the Internet is down does the script break?
-Sean

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bouver, Mark
Sent: Friday, May 05, 2006 10:00 AM
To: [email protected]
Subject: RE: [Talk] Sending e-mails using SMTP from BWS.

1) You can send to more than one person by using a comma separated list
per the SMTP syntax. 

so

SendEmail "[EMAIL PROTECTED], [EMAIL PROTECTED]", "BWS Test email",
"This is a test SMTP email from BWS " & Now

Or, you can define a string variable for clarity

DistributionList = "[EMAIL PROTECTED]" & ", " & "[EMAIL PROTECTED]" &
", " & "[EMAIL PROTECTED]"
SendEmail DistributionList, "BWS Test email", "This is a test SMTP email
from BWS " & Now

2) They do connect to Microsoft's schema resource and utilize the CDO
templates. You can get more info on this from Microsoft at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfsystemwebmail.asp


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Neil Hans
Sent: Friday, May 05, 2006 10:33 AM
To: [email protected]
Subject: RE: [Talk] Sending e-mails using SMTP from BWS.


Mark,
I gave it a try and it works.  I have a couple of questions though.  (1)
How do I send to more than one e-mail recipient?  (2) What do the
.Item("http://...) commands do?  Do these commands connect to
Microsoft's web site?
Thanks for your help.  

Thom, thanks for your input as well.

- Neil


>>> [EMAIL PROTECTED] 5/4/2006 4:58:31 PM >>>
I use a simple user-defined function based on the Micrsoft template for
the purpose. It should work for you if you edit in the appropriate
spots. Let me know if you have any questions...

Function SendEmail(ToWhom, Subject, Body)

' Common SMTP mail sender module
' Returns T/F based on if mail was sent successfully

    SendMail = True

 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''
    ' Use CDOSYS (Built into XP, Manually register CDOSYS.DLL for use
under W2k
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''

    Const cdoBasic = 1 'Use basic (clear-text) authentication.
    Const cdoSendUsingPort = 2

    Dim iMsg
    Dim objConfig
    
    'Create message and configuration objects
    Set iMsg = CreateObject("CDO.Message")
    Set objConfig = CreateObject("CDO.Configuration")

    'Apply settings to the configuration object

    With objConfig.Fields

        ' Specify the authentication mechanism to basic (clear-text)
authentication.
 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";)
= cdoBasic
    
        ' The username for authenticating to an SMTP server
 
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername";) =
"Your.Account"
    
        ' The password used to authenticate to an SMTP server
 
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword";) =
"Your.Password"

        ' Specify how to send (by port or pickup directory)
 
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing";) =
cdoSendUsingPort
    
        'Specify mail server
 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver";) =
"yoursmtpserver.domain"
    
        'Specify the timeout in seconds
 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontime
out") = 10

        ' The port on which the SMTP service specified by the smtpserver
field is listening for connections (typically 25)
 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) =
25
    
        'Use SSL for the connection (False or True)
 
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl";) =
False

        .Update

    End With

    Dim sTo
    Dim sCC
    Dim sFrom
    Dim sSubject
    Dim sTextBody

    sTo = Trim(ToWhom)
    
    'If Hour(Time) > 6 Then ' only page from 6am - midnight, quiet mid
to 6am
    'sCC = OnCallPager & ", " & MarkPager
    'Else
    'sCC = ""
    'End If
    
    sFrom = SupportEmail
    sSubject = Subject
    sTextBody = Body

    'Apply the settings to the message object
    With iMsg
        Set .Configuration = objConfig
        .To = sTo
        .From = sFrom
        .CC = sCC
        .Subject = sSubject
        .TextBody = sTextBody
    
        Err.Clear
        On Error Resume Next
    
        'Send message
        .Send

        ' CDOSYS cannot return T/F based on sent status...
        If Err.Number <> 0 Then
            SendMail = False
        End If
        
        On Error GoTo 0

        
    End With

    ' cleanup mail objects
    Set iMsg = Nothing
    Set objConfig = Nothing
    
End Function

You can test the above like so...

Sub TestEmail()
SendEmail SupportEmail, "BWS Test email", "This is a test SMTP email
from BWS " & Now
End Sub


Mark Bouver
Sr. System Analyst
Good Samaritan Medical Center
561-671-7008
-----Original Message-----
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] Behalf Of Neil Hans
Sent: Thursday, May 04, 2006 5:50 PM
To: [email protected] 
Subject: [Talk] Sending e-mails using SMTP from BWS.


Hello.
Has anyone tried to send e-mails from their BWS script using SMTP?  I
will not have an e-mail client (MS Outlook, GroupWise, etc.) loaded on
the PC that will be running my BWS script, but it can access an external
SMTP server.

Thanks.

Neil Hans
Alegent Health
Omaha, NE
(402) 717-1079
Confidentiality Notice: This e-mail message, including any attachments, is for 
the use of the intended recipient(s), and may contain legally privileged and 
confidential information. Any unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please do 
not read, copy, or use it, and do not disclose it to others. Please notify the 
sender of the delivery error by replying to this message, then delete it from 
your system, and destroy all copies. Thank you.

Reply via email to