Sending an e-mail with or without attachment.

 

When ScriptEZ.API based script file is running, an identification area is appended

to the system menu of the console windows as following:

 

 

'//////////////////////////////////////////////////////////////////////////////

' Author: SY

' Copyright (c) 2011

' Demo ScriptEZ.API based application which uses facilities from RAD API:

' . SendMail(…) based on SMTP (Simple Mail Transfert Protocol)

' . Echo() method usage which displays always messages into a console window

'   instead of WScript.Echo() with 2 behaviours for cscript.exe or wscript.exe

' . ScriptEZ.API Remoting Control Interface usage by NPTelnet.exe program

'   (Connect to ScriptEZ.API process with <processid (PID)> as connection name)

'

' Purpose: Testing SendMail property

'//////////////////////////////////////////////////////////////////////////////

 

const SCRIPTEZ_API = "ScriptEZ.API" ' Component name

Dim ScriptEZMain

 

' start the script

'/////////////////

'On Error Resume Next

Main()

 

' Main Subroutine

'////////////////

Sub Main()

 

  ' instantiate component object

  Set ScriptEZMain = WScript.CreateObject(SCRIPTEZ_API)

  If Not IsObject(ScriptEZMain) Then Exit Sub

 

  ScriptEZMain.AppRegister

 

  ' Using SSL

  'r = ScriptEZMain.SendMail("smtp.gmail.com:465", _

  '                          "expediteur@gmail.com|expediteur|sesame", _

  '                          "destinataire@gmail.com,destinataire2@gmail.com", _

  '                          "Test sendmail","Corps du message"+vbLF+"Bye!","")

  'r = ScriptEZMain.Echo "SendMail call status over smtp.gmail.com: " + CStr(r)

 

  ' No SSL

  r = ScriptEZMain.SendMail("smtp.free.fr", _

                            "expediteur@gmail.com", _

                            "destinataire@gmail.com", _

                            "Test sendmail","Corps du message"+vbLF+"Bye!", _

                            "")

  ' r = 0 if OK

  ScriptEZMain.Echo "SendMail call status over smtp.free.fr: " + CStr(r)

 

  ' App unregister before ending

  ScriptEZMain.AppUnregister

  WScript.Sleep 4000

  Set ScriptEZMain = Nothing

 

End Sub