Page 1 of 1 1
Topic Options
#81985 - 2002-12-05 06:24 PM How do I send e-mail from KiXtart? (SMTP)
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
You can use one of the following methods:
  • Blat
  • Postie
  • COM - Howard Bullock's Win32Admin.DLL
  • COM (using Outlook)
  • COM - Using CDO (Collaborative Data Objects): Thanks Howard!!
  • Sendmail() - UDF

Blat (Freeware)
Available from - http://www.blat.net/Usage - File Operations #4
Blat - No file attached..
Code:
BREAK ON
$mailhost = 'smtp.server.com'
$recipient = 'admin@@server.com'
$sender = @userid+'@@server.com'
$mailLine = @ldrive+'Programs\blat.exe - -to $recipient -server $mailhost -subject "No H: drive" '
$mailLine = $mailLine+'-body "H: Drive is not found for @userid (@fullname)" -f $sender -q'
SHELL $mailLine


Blat - File Attached..
Code:
BREAK ON
$Attachment = @scriptdir+"\byname.txt"
$mailhost = 'smtp.server.com' ; -- fill in with your smtp server
$recipient = 'recip@@server.com' ; -- add in your e-mail address
$sender = @userid+'@@server.com'
$mailLine = @ldrive+'Programs\blat.exe $Attachment -to $recipient -server $mailhost -subject "No H: drive" '
$mailLine = $mailLine+'-body "H: Drive is not found for @userid (@fullname)" -f $sender -q'
SHELL $mailLine


POSTIE (Shareware)
Available from - http://www.infradig.com/postie/index.shtmlUsage - Password expiration for a service accountCode:
$mailhost = 'smtp.server.com' ; -- fill in with your smtp server
$recipient = 'recip@@server.com' ; -- add in your e-mail address
$mailLine = @ldrive+'Programs\postie.exe -host:$mailhost -to:$recipient -from:"testroute" '
$mailLine = $mailLine +'-s:"Test Results 1" -file:"byname.txt"'
SHELL $mailLine

Howard Bullock's Win32Admin.DLL
Available at - http://home.comcast.net/~habullock/Code:
 Method Email($MailHost, $To, $From, $Subject, $Body)
; Sends an email from your script.
; Be sure to double the "@" in the email address.
$Win32Admin = createobject("Win32Admin")

$mailhost = 'mailhost.xyz.com'
$to = 'habullock@@comcast.net'
$from = 'habullock@@comcast.net'
$subject = 'Test Message'
$body = 'Email from KiXtart is great!'

if $Win32Admin.Email($mailhost, $to, $from, $subject, $body)
? ? "Email to " + $to + " sent."
?
else
? ? "Email Failed! @serror"
?
endif


COM (Outlook)
Usage - Tester needed - Outlook and Outlook Express AutomationCode:
break on
$Root = CreateObject("Outlook.Application")
$MailItem = $Root.CreateItem(0)
$MailItem.Importance = 1
; - 2 high importance
; - 1 normal importance
; - 0 low importance
$MailItem.Subject = "Automation Test"
$MailItem.To = "user@@server.com"
$MailItem.Body = "Test info"
IF EXIST("C:\errorlog.txt")
$MailItem.Attachments.Add("C:\errorlog.txt")
ENDIF
$MailItem.Send
$Root = 0


Ok.. I want to send two attachments in Outlook..
Thanks cmarti Two attachments in an email sent from kix..
This assumes that C:\errorlog.txt and C:\secondlog.txt exist
Code:
break on
$Root = CreateObject("Outlook.Application")
$MailItem = $Root.CreateItem(0)
$MailItem.Importance = 1
; - 2 high importance
; - 1 normal importance
; - 0 low importance
$MailItem.Subject = "Automation Test"
$MailItem.To = "user@@server.com"
$MailItem.Body = "Test info"
$MailItem.Attachments.Add("C:\errorlog.txt")
$MailItem.Save
$MailItem.Attachments.Add("C:\secondlog.txt")
$MailItem.Send
$Root = 0

COM - Using CDO (Collaborative Data Objects)
Installing CDO for NTS
Code:
break ON
$= SetOption("WrapAtEol","On")

break on
$objCDO = CreateObject("CDONTS.NewMail")
IF @error <> 0
?@error " CDO not found"
SLEEP 2
EXIT 1
ENDIF
$objCDO.From = "sender@@server.com"
$objCDO.To = "recipent@@secondserver.com"
$objCDO.Subject = "Software Notification for PC"
$objCDO.Body = "More Testing"
$objCDO.BodyFormat = 0
$objCDO.MailFormat = 0
$objCDO.Send
$objCDO = 0


Software Requirements
The dynamic-link libraries for CDO 1.2.1 (CDO.DLL) and CDO 1.2.1 Rendering (CDOHTML.DLL) are MAPI client object libraries. As such, they require MAPI (the version of MAPI32.DLL installed with Microsoft® Exchange Server version 5.0, or above) and service providers—for example, the same service providers as with Microsoft Exchange Server. CDOHTML.DLL and CDO.DLL are included with Microsoft Exchange Server and are installed on the server when the installation option Active Server Components is selected. CDO 1.2.1 Rendering (CDOHTML.DLL) is intended for server-side use only.

Microsoft® Outlook™ 98 installs the CDO 1.2.1 libraries. To enable client applications to use CDO 1.2.1, install Microsoft Outlook 98. For server applications, install Microsoft Exchange Server version 5.5.

Note CDO works with Microsoft Outlook, but CDO.DLL is not installed with the Microsoft Outlook 97 setup program.

Using SendMail - Sendmail() - send mail with telnet

CDO For XP Systems (Update) > Thanks Ceej Sending Email using COM calls to CDO in KiX.:
Code:

$objEmail=CreateObject('CDO.Message')
IF @ERROR <> 0
?'CDO is not found - Please install First.'
SLEEP 2
EXIT
ENDIF
$objEmail.From='user@@company.com'
$objEmail.To='user@@company.com'
$objEmail.Subject='subject'
$msweb='http://schemas.microsoft.com/cdo/configuration/'
$smtp='smtp.company.com'
$objEmail.Textbody='The User: '+@userid+' on Worksation: '+@wksta+' could not get to subject'
;$objEmail.AddAttachment ("C:\Somedir\somefile.txt") ;Attach a File
$objEmail.Configuration.Fields.Item($msweb+'sendusing').value=2
$objEmail.Configuration.Fields.Item($msweb+'smtpserver').value=$smtp
$objEmail.Configuration.Fields.Item($msweb+'smtpserverport').value=25
$objEmail.Configuration.Fields.Update
$objEmail.Send

?"ERROR @ERROR: @SERROR"

Sleep 5


_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#81986 - 2004-02-25 02:37 PM Re: How do I send e-mail from KiXtart? (SMTP)
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
With -
COM (using Outlook)

Under Outlook XP or greater, you will get security warnings about the program trying to send a message on your behalf.

Two ways to get around this:
(1) Download ClickYes - It will not work if the machine locks, but will if you unlock it. Also, look at the example code displayed on the site to use this.
(2) Review this document - However, it appears to have some limitations.

{Editor's note - Thanks Lonkero!}
is not fully correct.
we use office 2k sr-1 sp3 and it gives the same warnings.
{/Edit}

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#204543 - 2012-03-22 05:42 PM Re: How do I send e-mail from KiXtart? (SMTP) [Re: Kdyer]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
There is also a newer version of Sendmail() found here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=201907#Post201907

Top
Page 1 of 1 1


Moderator:  Jochen, Radimus, Glenn Barnas, Allen, Arend_, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 686 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.058 seconds in which 0.025 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org