web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

About sending mail

(0) ShareShare
ReportReport
Posted on by 35

I am trying to send mail from the system. How can I solve this problem?

****************************************************************************************************************************

void LmkAkviteBosOlanSatir(PurchLine _Line)

{
SysMailer mail = new SysMailer();
SysemailParameters param=SysemailParameters::find();
str mailicerigi,mailsatiri;
PurchLine _PurchLine;
PurchTable _PurchTable;
InventClosing _InventClosing;
;
{

mailicerigi ="<html> <head> <br>"+PurchTable::find (this.recVersion)"Satınalma <br>"+
this.recVersion+" Aktivite Tanmlı Olmayanlar Maddeler." +"</b> </head> <body> <table>;

while select _PurchLine
where _PurchLine.BuzProjActivityNumber == " "
&& _PurchLine.ItemId like "9*"

join _PurchTable where _PurchTable.PurchId == _PurchLine.PurchId
&& _PurchTable.BuzOrderDate
&& _PurchTable.PurchStatus =="Invoiced"

if(_InventClosing.Transdate < _PurchTable.BuzOrderDAte)


{
mailsatiri = strFmt("%1 %2 "PurchTable.PurchId,PurchLine.ItemId);
mailicerigi += "<tr> <td> <br>" + mailsatiri + "</tr> </td>";
}
}

mailicerigi = mailicerigi + "</table> </body> </html>";

if(mailsatiri!="")
mail.quickSend(param.SMTPUserName,"xxx@mail.com","Bilgi",mailicerigi);
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Could you please check below code as it has similar implementation using SMTP server.

    (Sending Email using X++ code Dynamics Ax 2012 - using SMTP)

    community.dynamics.com/.../sending-email-using-x-code-dynamics-ax-2012

  • Mariano Gracia Profile Picture
    on at

    Why don't you just use the static method sendEmail from the SysEmailTable?, then you can use the standard mail queues, even more, you will be able to trace which mails have been send, which not, you can schedule to send again those mails that couldn't been send if there was a problem. I'm still surprised people writing code for sending emails when the standard just does it

  • bulent_ege Profile Picture
    35 on at

    Could you give some more info about it?

  • Mariano Gracia Profile Picture
    on at

    Use this link to setup email functionality in AX2012, I use to create an email template with a simple text and a single mark, then you can just replace the mark with the text you want to send. Once you have done it, with a few lines of codes you can create your emails:

    static void tutorialSysEmailTable(Args _args)
    {
        SysEmailTable   sysEmailTable;
        Map             mappings        = new Map(Types::String, Types::String);
        Filename        fileName = "";
        
        sysEmailTable = SysEmailTable::find('TUTORIAL'); // email template
        
        // Build your variable/text mappings
        mappings.insert('mark1', 'Replace this text with the desired one'); // mark1 is the mark in the email template
    
        
        // If you were using XSLT, here is an example of how to build the XML
        // but you would most likely create your own static method
        xml = EventActionEmail::createEmailParameterXml(mappings);
        
    
        SysEmailTable::sendMail(sysEmailTable.EmailId,
                                'en-gb', // language must be setup in the email template
                                'sendMailTo@mailprovider.com', // who are you sending the mail
                                mappings, // Variable mapping
                                fileName, // The route of the attached file
                                xml , // XML
                                true, // Traceable or not?
                                sysEmailTable.SenderName, // Sending user
                                true); // Use retries?
        
        // you can now see the email in /System administration/Periodic/E-mail processing/E-mail sending status
    }


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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans