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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.05.2014, 17:14   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
palleagermark: Read mails from a POP3 account with AX
Источник: http://www.agermark.com/2014/05/read...t-with-ax.html
==============

Often when you browse lists of new AX features and AOT objects, you stumble across something that makes you a bit curious.

In R3 I came across some Brazilian functionality where AX connects to an e-mail account, fetches some official government issued files and processes these.

So AX can read e-mails, eh!?

Oh yes, and the Brazilian stuff is backed by a very nice basic framework for doing so.

Here is a very simple piece of code to show how it works.
X++:
static void Job1(Args _args)
{
    SysEmailAccount         sysEmailAccount;
    SysEmailAccountList     sysEmailAccountList = SysEmailAccountList::construct();
    SysEmailReader          sysEmailReader      = SysEmailReader::construct();
    SysEmailMessageReadList sysEmailMessageReadList;
    SysEmailMessageRead     sysEmailMessageRead;
    
    // Setup the account
    sysEmailAccount = SysEmailAccount::newAccount('pop-mail.outlook.com', 'someone@outlook.com', 'your_password', 995, true);
    
    // Add the account to a list of accounts to be checked
    sysEmailAccountList.add(sysEmailAccount);
    
    // Get a list of unread meassages
    sysEmailMessageReadList = sysEmailReader.getUnreadEmailMessages(sysEmailAccountList);
    
    // Loop over the list of unread mesages
    while (sysEmailMessageReadList.moveNext())
    {
        // Get the current message from the message loop
        sysEmailMessageRead = sysEmailMessageReadList.current();
        
        // Work with this message(show the subject line)
        info (sysEmailMessageRead.parmSubject());
    }
}
In a production environment you should of course not keep your account and password in clear text. Look into how the framework works with encrypted values for these, by checking the Brazilian feature.

I tried to test this with my Outlook.com account. If you do that and you have two-step verification turned on, you need to turn off two-step verification while testing or create a new app password to login with. Remember to enable two-step verification again if you disable it.

Also I tried to read messages with the Danish letters "ÆØÅ" - that didn't come out nicely. You probably need to do some extra work with the received text to set the right encoding. I didn't look into this and I'd love to hear if someone does.

In AX under "System administration / Setup / System / E-mail client constraints" you can find some setting of importance to this feature.

Источник: http://www.agermark.com/2014/05/read...t-with-ax.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось mazzy; 11.05.2014 в 23:10.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
palleagermark: How to make a ZIP file from AX 2012 R2 CU7 Blog bot DAX Blogs 0 07.04.2014 11:11
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
axinthefield: Top 10 issues discovered from Dynamics AX Health Check Blog bot DAX Blogs 0 27.06.2013 19:11
palleagermark: Create a 64-bit encoded string from an image in AX Blog bot DAX Blogs 0 22.01.2010 15:05
palleagermark: Channel 9 video: Dynamics AX Version Control interview from Convergence in Copenhagen 2008 Blog bot DAX Blogs 0 30.01.2009 16:05

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 06:44.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.