1- We need first to check System Administration >> Setup >> Email parameters
2- Create below Method to use in your Class
public static void SendMail(str strsenderName , str subject, str strbody, UserId userId )//= "sheriffayed")
{
SysOutgoingEmailTable outgoingEmailTable;
SysEmailItemId nextEmailItemId;
Map map;
str SenderName, SenderEmail, To , Body;
;
SenderName = strsenderName;
SenderEmail = "admin@xxx.com";
To = SysUserInfo::find(userId).Email;
Subject = subject;
Body = strbody ; // "<B>Test Body of the email</B>";
nextEmailItemId = EventInbox::nextEventId();
outgoingEmailTable.EmailItemId = nextEmailItemId;
outgoingEmailTable.IsSystemEmail = NoYes::No;
outgoingEmailTable.Sender = SenderEmail;
outgoingEmailTable.SenderName = SenderName;
outgoingEmailTable.Recipient = To;
outgoingEmailTable.Subject = SysEmailMessage::stringExpand(Subject, map);
outgoingEmailTable.Priority = eMailPriority::Normal ;
outgoingEmailTable.WithRetries = false;
outgoingEmailTable.RetryNum = 0;
outgoingEmailTable.UserId = userId;
outgoingEmailTable.Status = SysEmailStatus::Unsent;
outgoingEmailTable.Message = Body;
outgoingEmailTable.LatestStatusChangeDateTime = DateTimeUtil::getSystemDateTime();
outgoingEmailTable.insert();
}
}
No comments:
Post a Comment