If Exist ("\\<server>\home\smc\creditlist\creditmgr.xls")
SendEmail ("IT Department", "Test E-mail", "Reply if you receive this".)
Else
SendEmail ("IT Department", "Test E-mail", "Reply if you receive this - ind bad".)
EndIf
Function SendEmail ($Recip, $Subject, $Text)
;Session.Logon now uses the default MAPI profile as found in the registry.
If @INWIN = 2
; Windows 98 profile
$DefaultProfile =
ReadValue("HKEY_CURRENT_USER\Software\Microsoft\" +
"Windows Messaging Subsystem\Profiles", "DefaultProfile")
Else
; Windows 2000 profile
$DefaultProfile =
ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\" +
"CurrentVersion\Windows Messaging Subsystem\Profiles", "DefaultProfile")
EndIf
$Session = CreateObject("MAPI.Session")
$Session.Logon($DefaultProfile)
;Create the core MAPI objects--Message and Recipient
$Message = $Session.Outbox.Messages.Add
$Recipient = $Message.Recipients.Add
;Compose the message
$Message.Subject = $Subject
$Message.Text = $Text
;Translating email address so the '@' symbol doesn't confuse
;KiXtart as being a macro.This is better than having to remember
;to Use '@@' in the Function argument, although either method will work.
If InStr ($Recip, "<unknown:") <> 0
$Recip = SubStr($Recip, 1, InStr($Recip, "<unknown:") - 1) + "@@" +
SubStr($Recip, InStr($Recip, "<unknown:") + 9, Len($Recip))
EndIf
;Select recipient
; Note: Recipient.Type values are as follows:
; 1 = To
; 2 = Cc
; 3 = Bcc
$Recipient.Name = $Recip
$Recipient.Type = 1
$Recipient.Resolve
;Sending the message
$Message.Send
$Session.DeliverNow
;Disconnecting MAPI Session
$Session.Logoff
;Object Cleanup
$Recipient = 0
$Message = 0
$Session = 0
EndFunction