class SendEmail extends RunBase
{
SysEmailId emailId;
DialogField dlgEmailId;
CustTable custTable;
LanguageId languageId;
#define.CurrentVersion(1)
#localmacro.CurrentList
emailId
#endmacro
}
void new()
{;
super();
languageId = infolog.language();
}
public CustTable parmCustTable(
CustTable _custTable = custTable)
{;
custTable = _custTable;
return custTable;
}
public container pack()
emailemailsending in Oulook, steps{
return [#CurrentVersion, #CurrentList];
}
public boolean unpack(container packedClass)
{
int version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
return true;
default :
return false;
}
return false;
}
public static SendEmail construct(CustTable _custTable)
{
SendEmail sendEmail;
;
sendEmail = new SendEmail();
sendEmail.parmCustTable(_custTable);
return sendEmail;
}
protected Object dialog()
{
Dialog dialog;
;
dialog = super();
dialog.caption("Select email template");
dlgEmailid = dialog.addFieldValue(
typeid(SysEmailId), emailId);
return dialog;
}
public boolean getFromDialog()
{;
emailId = dlgEmailId.value();
return true;
emailemailsending in Oulook, steps}
str subject()
{
return SysEmailMessageTable::find(
emailId, languageId).Subject;
}
str processMappings(str _message)
{
Map mappings;
;
mappings = new Map(Types::String, Types::String);
mappings.insert('name', custTable.Name);
mappings.insert('company', CompanyInfo::name());
return SysEmailMessage::stringExpand(_message, mappings);
}
str message()
{
COM document;
COM body;
str ret;
SysEmailMessageTable message;
#help
;
message = SysEmailMessageTable::find(emailId, languageId);
ret = this.processMappings(message.Mail);
ret = WebLet::weblets2Html4Help(ret, '');
document = new COM(#HTMLDocumentClassName);
SysEmailTable::insertHTML2Document(document, ret);
body = document.body();
emailemailsending in Oulook, stepsif (!body)
{
return '';
}
return body.outerText();
}
public boolean validate()
{;
if (!custTable)
{
return false;
}
return true;
}
public void run()
{
SysInetMail mail;
;
mail = new SysInetMail();
mail.parmForceSendDialog(true);
mail.sendMail(
custTable.Email,
this.subject(),
this.message(),
true);
}
public static void main(Args _args)
{
SendEmail sendEmail;
;
if (!_args || !_args.record())
{
throw error(Error::missingRecord(funcname()));
}
sendEmail = SendEmail::construct(
_args.record());
if (sendEmail.prompt())
{
sendEmail.run();
}
}