AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.10.2012, 19:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
ax-erp: How to send E-Mail In Microsoft Dynamics AX
Источник: http://microsoft-dynamics-ax-erp.blo...microsoft.html
==============

There are more than one way to send emails through Microsoft Dynamics AX system, using X++ code.
The most recommended way is to use the standard mail mechanism built in the system.
That way copies of any email you send will be save in the Email sending status form (based on tableSysOutgoingEmailTable) and you will be able to monitor and see status of sent emails:

http://theaxapta.blogspot.in/

(Administration -> Periodic -> E-mail processing -> Email sending status; Form: SysOutgoingEmailTable)
This mechanism based on a system table that contain the emails, and a batch job that scan that table and send the emails, one by one (with retries and status controlling).
This technique is very simple to use and therefore it has some disadvantages; you cannot add attachments or use advanced email properties (cc, bcc, priority flag, etc).
To use this mechanism, first you have to make sure you a SMTP server configured and running.
Go to
Administration -> Setup -> E-mail parameters
and fill the required settings:



(Form: SysEmailParameters)
Next step is to make sure the E-mail distributor batch is up and running.
Go to
Basic -> Inquiries -> Batch Job and check if the batch job exists with status Executing orWaiting.



(Form: BatchJob)
If it doesn’t, you can activate it from Administration -> Periodic -> E-mail processing -> Batch.
Now we are ready to implement our X++ code:
void SendMail()
{
SysMailer mail;
SysOutgoingEmailTable outgoingEmailTable;
SysEmailItemId nextEmailItemId;
Map map;
str SenderName, SenderEmail, To, Subject, Body;
;

SenderName = "X++.info";
SenderEmail = "Sender@xplusplus.info";
To = "recipient@xplusplus.info";
Subject = "Subject line for the email";
Body = "Body of the email";

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 = curUserId();
outgoingEmailTable.Status = SysEmailStatus::Unsent;
outgoingEmailTable.Message = Body;
outgoingEmailTable.LatestStatusChangeDateTime = DateTimeUtil::getSystemDateTime();
outgoingEmailTable.insert();
}
The result of the example above will shown in the Email sending status form as mentioned above.


(Administration -> Periodic -> E-mail processing -> Email sending status; Form: SysOutgoingEmailTable)

- I Hope it will usefull for all of you...
-Harry


Источник: http://microsoft-dynamics-ax-erp.blo...microsoft.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
Старый 18.10.2012, 20:07   #2  
Vadik is offline
Vadik
Модератор
Аватар для Vadik
Лучший по профессии 2017
Лучший по профессии 2015
 
3,631 / 1849 (69) ++++++++
Регистрация: 18.11.2002
Адрес: гражданин Москвы
Цитата:
Сообщение от Blog bot Посмотреть сообщение
X++:
SenderName = "X++.info";
SenderEmail = "Sender@xplusplus.info";
To = "recipient@xplusplus.info";
Subject = "Subject line for the email";
Body = "Body of the email";

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 = curUserId();
outgoingEmailTable.Status = SysEmailStatus::Unsent;
outgoingEmailTable.Message = Body;
outgoingEmailTable.LatestStatusChangeDateTime = DateTimeUtil::getSystemDateTime();
outgoingEmailTable.insert();
I Hope it will usefull for all of you...
I hope Harry will learn how to use cross-references some day..
__________________
-ТСЯ или -ТЬСЯ ?
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 8 Blog bot Dynamics CRM: Blogs 1 30.04.2016 10:26
ax-erp: Creating SSRS-Reports in Dynamics AX 2012 – What’s no longer possible in AX-reports Blog bot DAX Blogs 0 18.07.2012 12:11
Microsoft Dynamics CRM Team Blog: The Microsoft Dynamics CRM Swiss Army Knife Blog bot Dynamics CRM: Blogs 1 19.04.2012 08:20
Microsoft Dynamics CRM Team Blog: Update Rollup 3 for Microsoft Dynamics CRM 2011 Blog bot Dynamics CRM: Blogs 3 03.08.2011 09:11
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 08:35.