11.05.2014, 17:14 | #1 |
Участник
|
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()); } } 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. |
|
|
|