` Printed Icetips Article

Icetips Article



Windows API: Getting the Messaging/Email templates to work
2002-12-31 -- Mike Jenkins
 
Newsgroups: comp.lang.clarion


Hi,

I noted a number of posts asking for assistance in getting the example
SMTP
to work within their APP.  Having hit the same problem, I settled down
to document the steps.

Open an APP you want to email-enable and click
Global
Extensions
Insert
and select Global Document Handling, Addressbook and Transport
Settings
Complete . . .
Sender Domain = the domain of the email that you'll test with.  EG for
sender email address mike@hotmail.com, put hotmail.com
Default SMTP server = the IP address of the server through which you
transmit.  EG 10.0.0.4 for an IP on an internal network.  If you're
unsure
of the IP address, contact your ISP's helpline and ask them.  I didn't
try
the FQDN, just the IP.
Default SMTP port = the default is 25

Click on SENDER SETTINGS and complete the three fields with global
variables.  I used CSTRING(60) . . .
!SMTP:SenderAddress
!SMTP:FromHeaderAddress
!SMTP:FromHeaderName
Click OK
Click OK

I then created a procedure to do the actual transmission so that I
could
call it from various points within my code.  So press Insert and name
the
procedure.  EG SendEmail.

Select Generic Window Handler
Click Extensions
Click Insert
Select Document Send - Document Send Extension
Click Message Settings and set Message Body Source to NONE
Click OK
Click Window
Select Window (IE without OK & Cancel)
Right-click and select Embeds
Insert the source below into the OpenWindow embed
Save entry and ensure that you select Procedures in the module from
which
you wish to call SendEmail.  All you have to do is prime your globals
and
call SendEmail.


!OpenWindow

 eMail.DefaultServer = SMTP:DefaultServer
 eMail.DefaultPort   = SMTP:ServerPort
 eMail.Sender        = clip(SMTP:SenderAddress)
 if clip(SMTP:FromHeaderName)  = '' then
    eMail.From = '<<' & clip(SMTP:FromHeaderAddress) & '>'
 else
    eMail.From = '"' & clip(SMTP:FromHeaderName) & '" <<' &
clip(SMTP:FromHeaderAddress) & '>'
 .
 eMail.SenderDomain = SMTP:SenderDomain
 Addresses.AddRecipient(SMTP:RecipientAddress, SMTP:RecipientName,
SendTo,
SMTP,)

 Message.Description = SMTP:Subject
 Message.AddBody(clip(SMTP:BodyText) & '<13,10,13,10>'
 Message.TextOnly = True ! Drop all MIME headers and encoding.
 Message.Send()

 post(Event:CloseWindow)



where global variables are all CSTRING(60) unless otherwise noted . .
.
SMTP:DefaultServer = IP of your ISP SMTP server
SMTP:ServerPort = default 25
SMTP:SenderAddress = your email address
SMTP:FromHeaderName = Name of from address
SMTP:FromHeaderAddress = your email address
SMTP:SenderDomain = domain portion of your email address
SMTP:RecipientAddress = recipient's email address
SMTP:RecipientName = recipient's name or blank
SMTP:Subject = subject of email CSTRING(100)
SMTP:BodyText = body of email CSTRING(5000)



Printed November 23, 2024, 5:10 pm
This article has been viewed/printed 35284 times.
Google search has resulted in 101 hits on this article since January 25, 2004.