Notifications
Announcements
No record found.
Is it possible to save sent email and attach it in document attachment after user sent an email from interactive form?
Yes, it should be possible.
If you have more questions, give us more context, include the product you're asking about (e.g. AX 2012 or D365FO).
How can I do it with x++?
I want to coding it in D365FO
Moved from Dynamics AX Forum.
Please tell us more about the situation.
Now, I can write code to open an email editing form by using this line of code
SysMailerFactory::sendInteractive(messageBuilder.getMessage())
What I want to do is, when user click send button, I want to attach email file to document attachment (Docuref).
How can I do that?
For example:
System.Net.Mail.MailMessage message = messageBuilder.getMessage(); if (SysMailerFactory::sendInteractive(message)) { // ... your logic ... }
I don't know what exactly you want to attach. You'll need to convert the message object to what you want.
Then call one of the attach* methods in DocumentManagement class to actually attach the email to a record.
I want to attach email content that user edit in interactive form, maybe saving it to Html file or Pdf.
How can I get email content from interactive form?
Don't you have that in the message?
Thanks Martin!
Here is line of code that I write to achieve that. Is there any more proper way to do it?
public void generateEmail(FlxUs_PortJournal _portJournal) { var builder = new SysMailerMessageBuilder(); Filename fileName = _portJournal.CallId ".htm"; builder.addTo(toEmail); builder.addCc(ccEmail); builder.setFrom(sysEmailTable.SenderAddr, sysEmailTable.SenderName); builder.setSubject(subject); builder.setBody(messageBody); var message = builder.getMessage(); if(SysMailerFactory::getInteractiveMailer().sendInteractive(message)) { str messageString = strFmt("From: %1To: %2CC: %3Subject: %4%5", message.From.Address, message.To, message.CC, message.Subject, message.Body); System.Text.Encoding encoding = System.Text.Encoding::UTF8; System.Byte[] array = encoding.GetBytes(messageString); System.IO.MemoryStream stream = new System.IO.MemoryStream(array); DocumentManagement::attachFile( _portJournal.TableId , _portJournal.RecId , _portJournal.DataAreaId , "File" , stream , fileName , System.Web.MimeMapping::GetMimeMapping(fileName) , System.IO.Path::GetFileNameWithoutExtension(fileName)); } }
From: %1To: %2CC: %3Subject: %4
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 584 Most Valuable Professional
André Arnaud de Cal... 499 Super User 2025 Season 2
Sohaib Cheema 254 User Group Leader