Created
February 22, 2014 11:29
-
-
Save seanbamforth/9152417 to your computer and use it in GitHub Desktop.
Using the SELECT email Libraries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use Windows | |
Use cSelectMailer.pkg | |
Use emailAudit.pkg | |
//register a new SELECT emailer. This knows how to send emails. | |
//But we also need to tell it how to audit those emails and read system flags. | |
Object oChilkatMailer is a cSELECTMailer | |
//ghEmailObject is a global variable for your convenience. It's used as a bridge between | |
//global emailing functions and the emailing option. | |
Move (Self) to ghEmailObject | |
//oEmailFlags is a global object that knows what the SMTP Server is. | |
//You need to tell it that it can ask this new object what the system flags | |
//say these values are. | |
Set phFlagObject of oEmailFlags to (Self) | |
//if you set phFlagObject, then you also need to create a "Flag" function. | |
//It's pretty simple - You just create a procedure called flag that knows how to | |
//read a system flag. e.g. | |
Function flag String sCode Returns String | |
Function_Return (flagvalue(Self)) | |
End_Function | |
//This is how the emails get audited. | |
//ghMailAuditor is a specific library that does the auditing. | |
//You need to use your own auditing code here. | |
Procedure AuditEmail String sFrom String sTo String sCC String sSubject String sBody String sAttachment String sResponse | |
Integer hoMailMan | |
String sPort | |
String sSmtpHost | |
String sUsername | |
String sURN | |
Get oMailSender to hoMailMan | |
Get ComSmtpPort of hoMailMan to sPort | |
Get ComSmtpHost of hoMailMan to sSmtpHost | |
Get ComSmtpUsername of hoMailMan to sUsername | |
Move (sUsername+"@"+sSmtpHost+":"+sPort) to sSmtpHost | |
Move (audit_email(ghMailAuditor,sSmtpHost,sFrom,sTo,sCC,sSubject,sBody,sAttachment)) to sURN | |
Send Audit_email_Response to (ghMailAuditor) sURN sResponse | |
End_Procedure | |
End_Object | |
//Finally - There are a couple of global functions we use all the time at SELECT. | |
//Here's how you connect them to the new library. | |
Function sendmail Global String sFrom String sTo String sCC String sSubjectIn String sData Returns String | |
String sReturn | |
Get doSendEmail of (ghEmailObject) sFrom sTo sCC sSubjectIn sData "" (False) to sReturn | |
Function_Return sReturn | |
End_Function | |
Function sendAttachment Global String sFrom String sTo String sCC String sSubjectIn String sData String sFileName Returns String | |
String sReturn | |
Get doSendEmail of (ghEmailObject) sFrom sTo sCC sSubjectIn sData sFileName (False) to sReturn | |
Function_Return sReturn | |
End_Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment