Alaska Software Inc. - sending emails directly
Username: Password:
AuthorTopic: sending emails directly
Chris Palmersending emails directly
on Tue, 03 Mar 2009 11:29:47 +0000
Please can anybody offer any information on how to send emails directly from 
the system without using Outlook or any other external software !

Any adice would be welcome
Thanks
Thomas Braun
Re: sending emails directly
on Tue, 03 Mar 2009 14:34:14 +0100
Chris Palmer wrote:

> Please can anybody offer any information on how to send emails directly from 
> the system without using Outlook or any other external software !

http://www.marshallsoft.com/see4xb.htm

It is worth every cent...


Thomas
Garry Allen Re: sending emails directly
on Tue, 03 Mar 2009 10:31:30 -0500
I agree wholeheartedly! It took me all of about 20 minutes.
Garry

Thomas Braun wrote:
> Chris Palmer wrote:
> 
>> Please can anybody offer any information on how to send emails directly from 
>> the system without using Outlook or any other external software !
> 
> http://www.marshallsoft.com/see4xb.htm
> 
> It is worth every cent...
> 
> 
> Thomas
Clifford Wiernik Re: sending emails directly
on Tue, 03 Mar 2009 20:41:01 -0600
I have purchased but don't really use see4xb.  It is good though.  If 
you have the professional subscription, you can use asinet.  Here is 
some sample code.

*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+
*+    FUNCTION LB_SendMail( cSMTPServer, cSender, aRecipient, cSubject, ;
*+                          cReplyTo, xAttachment, cText, lSendMail, 
cCC, cBCC, lDisplayMsg, lShowProgress, aXHeaders)
*+
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+
FUNCTION LB_SendMail( cSMTPServer, cSender, aRecipient, cSubject, ;
                       cReplyTo, xAttachment, cText, lSendMail, cCC, 
cBCC, lDisplayMsg, lShowProgress, aXHeaders )
   LOCAL oMail, oSender, oRecipient, oSmtp, lError := .T., i
   LOCAL lConnectOK, cDate, dCurDate := date(), cCurTime := time(), 
cCurDate := DTOS(dCurDate), cTimeZone

   DEFAULT cSubject        TO '',        ;
           cReplyTo        TO cSender,   ;
           cText           TO '' ,       ;
           xAttachment     TO SPACE(50), ; 

           lSendMAil       TO .T.,       ;
           cCC             TO '',        ;
           cBCC            TO '',        ;
           lDisplayMsg     TO .T.,       ;
           lShowProgress   TO .F.,       ;
           aXHeaders       TO {}

   IF empty(cReplyTo)
     cReplyTo := cSender
   ENDIF

   IF lShowProgress 

     m->g_oMsgbox:setcaption('Sending Email')
   ENDIF

   cSubject := strtran(cSubject,":","-")

   IF lSendMail
     oMail       := MIMEMessage():new()
     oSender     := MailAddress():new( '<'+lower(Alltrim(cSender))+'>' )

      Assemble the e-mail
     FOR i = 1 To LEN(aRecipient)
       IF !empty(aRecipient[i])
         oRecipient  := MailAddress():new( 
<'+lower(Alltrim(aRecipient[i]))+'>' )
         oMail:addRecipient( oRecipient  )
       ENDIF
     NEXT

     oMail:setFrom( oSender     )
     oMail:setSubject( Alltrim(cSubject) )
     oMail:setMessage( cText       )

     cTimeZone := val(setlocale(NLS_ITZBIAS))/60*100
     cTimeZone := strzero(cTimeZone,5)
     cDate     := left(cdow(dCurDate),3)+', '+right(cCurDate,2)+' 
'+left(cMonth(dCurDate),3)+        ;
                  ' '+left(cCurDate,4)+' '+cCurTime+' '+cTimeZone
     oMail:addHeader( "Date", cDate)

     oMail:addHeader( "Reply-To", '<'+lower(Alltrim(cReplyTo))+'>' )
     IF !empty(cCC)
       oMail:addHeader( "CC",     '<'+lower(Alltrim(cCC))+'>' )
     ENDIF
     IF !empty(cBCC)
       oMail:addHeader( "BCC",    '<'+lower(Alltrim(cBCC))+'>' )
     ELSE
       oMail:addHeader( "BCC",    '<'+lower(Alltrim(cSender))+'>' ) 

     ENDIF

     IF len(aXHeaders) > 0
       FOR i := 1 to len(aXHeaders)
         oMail:addHeader( aXHeaders[i,1], '<'+aXHeaders[i,2]+'>')
       NEXT
     ENDIF

     oMail:setContentType('text/html')

     IF valtype(xAttachment) == 'C' 

       xAttachment := {xAttachment}
     ENDIF

     FOR i := 1 to len(xAttachment)
       IF !empty(xAttachment[i])
         oMail:attachFile( xAttachment[i] )
       ENDIF
     NEXT 


     oSmtp := SMTPClient():new( Alltrim(cSMTPServer) )

     lConnectOK := oSmtp:connect()

     IF lConnectOK 

       oSmtp:send( oMail )
       oSmtp:disconnect()
     ELSE
       IF lDisplayMsg
         LB_Warning({"Unable to connect to mail server"},'E-Mail error')
       ENDIF
       lError := .F.
     ENDIF

     SET TIME TO HH:MM:SS 

   ENDIF

   IF lShowProgress 

     m->g_oMsgbox:setcaption('')
   ENDIF

RETURN lError


Garry Allen wrote:
> I agree wholeheartedly! It took me all of about 20 minutes.
> Garry
> 
> Thomas Braun wrote:
>> Chris Palmer wrote:
>>
>>> Please can anybody offer any information on how to send emails 
>>> directly from the system without using Outlook or any other external 
>>> software !
>>
>> http://www.marshallsoft.com/see4xb.htm
>>
>> It is worth every cent...
>>
>> 
>> Thomas