Hello All,
Thank you for your answers :)
Here is my code is running by a bouton in form, I can't see the list of sent emails so see the status of each email if it's sent or blocked or pending !!
Do you have any idea on how to view and reprocess blocked emails ?
FYI : The table outgoingEmailTable is empty
public void sendMail()
{
SysEmailParameters emailParameters = SysEmailParameters::find();
SMTPRelayServerName relayServer;
SMTPPortNumber portNumber;
SMTPUserName userName;
SMTPPassword password;
Str1260 subject;
Str1260 body;
InteropPermission interopPermission;
SysMailerNet mailer;
System.Exception e;
MapEnumerator mapEnum;
;
if (!emailPrimary)
{
throw warning("Email invalide");
}
if (parameters.EmailNotification == NoYes::No)
{
return;
}
if (emailParameters.SMTPRelayServerName)
relayServer = emailParameters.SMTPRelayServerName;
else
relayServer = emailParameters.SMTPServerIPAddress;
portNumber = emailParameters.SMTPPortNumber;
userName = emailParameters.SMTPUserName;
password = SysEmailParameters::password();
subject = strFmt("TESTMAIL: %1", mwoId);
body = notes;
CodeAccessPermission::revertAssert();
try
{
interopPermission = new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
mailer = new SysMailerNet();
mailer.SMTPRelayServer(relayServer,portNumber,userName,password, false);
mailer.fromAddress(userName);
mailer.tos().add(emailPrimary);
mapEnum = emailMap.getEnumerator();
while (mapEnum.moveNext())
{
mailer.ccs().add(mapEnum.currentValue());
}
mailer.subject(subject);
mailer.htmlBody(body);
mailer.enableSsl(true);
mailer.sendMail();
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
e = ClrInterop::getLastException();
while (e)
{
info(e.get_Message());
e = e.get_InnerException();
}
CodeAccessPermission::revertAssert();
}
}