Design Requirement
To meet one of our solution requirement, we had to built an interface in AX which should be able to read an email with a particular subject line and download the invoice attachment to do further processing and posting of the same.
I searched on the web and most of the existing solutions or blog posts are about AX Sending emails where AX Communicates to Microsoft Exchange Server and is tightly coupled with Outlook client to be installed on AOS or client.
In our server topology, our infrastructure/IT team at the client's place won't allow us to install any office tools on the server, thereby ruling out the option of installing Outlook Client on the server.
Solution
After some research, I found that EWS is the way to go. EWS stands for Exchange Web Services which is an extensible component for clients to connect to your Exchange Server and can read emails from a particular mailbox. Here are the steps:
a. Download EWS SDK by going to this url http://www.microsoft.com/downloads/en/details.aspx?FamilyId=190F71A4-7B5F-4A4C-99BA-9BD032E16E15&displaylang=en,
Note, we have a separate SDK for EWS 2010. I downloaded the above SDK as our client is still on Exchange Server 2007
b. Install the Exchange Service msi which copies the Exchange Web Service dll to C:\Program Files\Microsoft\Exchange folder
c. Retrieve this dll and copy to your assembly on the AOS Server. i.e. you can drag and drop this dll file into C:\Windows\assembly
d. Note that this assembly is a .Net assembly so for me the easiest way was to write a custom wrapper assembly in C# which consumes the Microsoft Exchange Web Service (i.e. the dll in step b)
e. Add this custom dll into your References node in AOT
f. Write a class in AX which invokes your custom assembly
g. In my scenario, all the code had to achieve is given the parameters of email id, subject and UNC path name (Network location), it looks up the Exchange Store, reads the email with that particular subject line and downloads the related invoice attachment and strips it to the folder location on the network
And all this achieved without any mess and just few lines of code. If anybody interested in code, feel free to write to me and I can send you the .cs file
Happy Dax'ing :)
Hi Dilip, I'm interested in your example .cs code. ;-)
ReplyDeleteCan you please mail me that?
greetz Geert (geert[@]pulse.nl)
Very interresting! I though about this some time but never knew how to read email from code. Can you send me the .cs file? Thanks!
ReplyDeleteDilip,
ReplyDeleteMay I have C# code ?
Thanks
Sandip
Can I kindly have the code?
ReplyDeleteHi Dilip,
ReplyDeleteI'm also interested in the code. Can you send it to mohamed.tassisto@student.artesis.be
Thank you,
M. TASSISTO
Hi Dilip,
ReplyDeleteCould you please send me the .cs code, I needed some help on this.
Thanks & Regards,
Shafiq Hussain
shafiqhussain@hotmail.com
Hi Dilip,
ReplyDeleteI'm very much interested in the .cs code. Can you email me that one? And I have a question. Is it possible to update tasks / contactpersons via this method?
Thanks a lot!
Greetings,
Marchel (mdleeuw@yahoo.com)
Hi Dilip, can you please send me the .cs code?
ReplyDeleteThanks
-Shiv
Hi Dilip,
ReplyDeletecan you please mail me the C# Code (tob@seelhof.de)?
Thanks in Advance and Best Regards,
Tobias
Hello Dilip,
ReplyDeleteEven we have a requirement where we need to download a pdf file from outlook email to a shared drive. Can u pls send the code ?
I never used Microsift dynamics. Do u think I need a microsoft dynamics expert to do this set-up or any dummy can do this code?
thanks,
shan (sshanbh@yahoo.com)
Hi Dilip,
ReplyDeletei'm intrested in the example code
Hi Dilip,
ReplyDeleteThis is great, can i get this .cs file please..
my email khalid_akkawi@windowslive.com
Can I get the Code please
ReplyDeletegus@kanimambo.com.au
Hello, can I havethe code as well?
ReplyDeleteThanks.
pepesifuentes@Hotmail.com
Hi Dilip, I'm interested in your example .cs code.
ReplyDeleteCan you please mail me that?
Luiz (ltartarotti@gmail.com)
Hi Can you also please send this code to me ?
ReplyDeleteHi Dilip,
ReplyDeleteI am having a AX 2012 Customization where i need to read an attachment in the email and load data into AX tables. Please send your code to my mail id : bharatvenkatraman@gmail.com for my reference.
Thanks in advance
Bharat V
Hi Dilip, would you send me the .cs and any code you can share with it? Thanks a lot
ReplyDeleteStefan
stefan.kale[@]polysol.com
This comment has been removed by the author.
ReplyDeleteHi!
ReplyDeleteCan you please send me the .cs file?
Thank you!
willardalec@yahoo.com
I'd live your example code also. My email is xebbskandalfylla.se
ReplyDeletewhy dont disclose you the code?
ReplyDeleteregards,
panliner shipping
pls disclose the code
ReplyDeletesend me the code.
ReplyDeleteHi, Dilip!
ReplyDeleteI have been looking for such opportunity for several days! Would you be so kind to send me the code?
My email is farvex@gmail.com
Thank you in advance.
Sergey.
Hi, Dilip!
ReplyDeleteVery interesting! I have been looking for such opportunity for several weeks!
Could you please send me the code?
My email is margus023@gmail.com
Thank you in advance.
Margus.
Can I have the code please.
ReplyDeleteharoon [dot] attari [at] gmail [dot] com
Thanks
Haroon
Hi, Dilip,
ReplyDeleteYour post is really appreciated. I need your code. My email address is abdullahagha@hotmail.com
Regards,
Abdullah.
Hi, dilip! really appreciate your post kindly send me the code. Email: abdullahagha@hotmail.com
ReplyDeleteSend me code. email: abdullahagha@hotmail.com
ReplyDelete