Цитата:
Сообщение от
dech
Мы лично в new() ничего не указываем, вот пример корректного использования.
Тоже в new() ничего не указываю, какой-то глюк в обычном функционале
X++:
public boolean sendEmail()
{
#define.Event("Event")
str liq_message;
SysMailer liq_Mailer;
SysMailerAddressField liq_tos;
SysEmailMessageTable message;
SysEmailTable emailTable;
boolean liq_mailInitialized;
Responsibility_ZTR responsibility;
SysUserInfo sysUserInfo;
SysCompanyUserInfo sysCompanyUserInfo;
boolean ret = false;
void liq_initMail()
{
SysEmailParameters parameters = SysEmailParameters::find();
InteropPermission interopPermission;
;
interopPermission = new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
liq_Mailer = new SysMailer();
if(parameters.smtpRelayServerName)
{
liq_Mailer.SMTPRelayServer(parameters.smtpRelayServerName,
parameters.smtpPortNumber,
parameters.smtpUserName,
SysEmailParameters::password(),
parameters.ntlm);
}
else
{
liq_Mailer.SMTPRelayServer(parameters.smtpServerIPAddress,
parameters.smtpPortNumber,
parameters.smtpUserName,
SysEmailParameters::password(),
parameters.ntlm);
}
liq_mailInitialized = true;
}
;
subjectMail = this.setSubjectMail();
liq_message = this.setMessage();
emailTable = SysEmailTable::find(#Event);
while select EmplId from responsibility
{
select UserId from sysCompanyUserInfo where sysCompanyUserInfo.EmplId == responsibility.EmplId
join Email from sysUserInfo where sysUserInfo.Id == sysCompanyUserInfo.UserId;
if(!liq_mailInitialized)
liq_initMail();
if (liq_Mailer != null && SysEmailDistributor::validateEmail(sysUserInfo.Email))
{
liq_Mailer.fromAddress(emailtable.SenderAddr);
liq_Mailer.subject(subjectMail);
liq_tos = liq_Mailer.tos();
liq_tos.clear();
liq_Mailer.tos().appendAddress(sysUserInfo.Email);
liq_Mailer.priority(1);
liq_Mailer.htmlBody(liq_message);
liq_Mailer.sendMail();
ret = true;
}
}
return ret;
}