Hi team,
I am going through this process where I have .msg file and its has table in the body and attachment on the mail how to extract the table and how to download the attachment from .msg file.
Hi @Majunu09
For this u can use a c# code to convert a .msg file to mailmessage object and then u can be to extract the attachemnts
Refer this link for more information on that
https://www.codeproject.com/Articles/32899/Reading-an-Outlook-MSG-File-in-C
Regards,
Nived N
@Palaniyappan
Can you explain me on the process " Read a.msg file and save attachment"?
@NIVED_NAMBIAR is there any other way caz I am not much in code…
check this
I think this would work your case, converting a .msg file to mailmessage object
The code shared in that thread can be used in a INVOKE CODE activity
@Palaniyappan , can you guide me,?
should I copy all the code("Dim OlApp
Dim Eml
Dim Arg
Set Arg = WScript.Arguments
Dim File
File = Arg(0)
Set OlApp = CreateObject(“Outlook.Application”)
Set Eml = OlApp.CreateItemFromTemplate(File)
Download(Eml)
Sub Download(objEml)
For Each Attch In objEml.Attachments
Attch.SaveAsFile “C:\temp" & Attch.FileName
Next
End Sub”) and apply on invoke code activity?
and what will be next step?
You can either pass this on INVOKE CODE activity or write in a notepad and save the file with .Vbs extension
Dim OlApp
Dim Eml
Dim Arg
Set Arg = WScript.Arguments
Dim File
File = Arg(0)
Set OlApp = CreateObject(“Outlook.Application”)
Set Eml = OlApp.CreateItemFromTemplate( File )
Download(Eml)
Sub Download(objEml)
For Each Attch In objEml.Attachments
Attch.SaveAsFile "C:\temp\"
& Attch.FileName
Next
End Sub
Here mention your filepath and once been saved as a file
Get the filepath of that file and pass it to START PROCESS activity as input and mention the argument like this
Cheers @Majunu09
@Palaniyappan I am getting this error.
@Palaniyappan @NIVED_NAMBIAR is there any other way to download the attachment in .msg file can you share screen shot or xaml file?
Hi @Majunu09
There is a way to try this but u had to use third party packages
It will works
First Install the below nuget package
From package manager.
Now use the below assign activity
mail_1 = Aspose.Email.Mapi.MapiMessage.FromFile(file_path of the msg file)
datatype of mail_1 : Aspose.Email.Mapi.MapiMessage
Then to access the subject (for example ) u can use
mail_1.Subject -----> will give u the subject of the mail in msg file.
Try this and let me know if it works for u as wellMain.xaml (4.5 KB)
use the above by installing the above dependencies
Hope this will help u
Regards,
Nived N
@NIVED_NAMBIAR thank you for the reply,
I get the subject of the msg file but how to download that attachment which is inside of it.
@Palaniyappan Hi dude,
can you help me out on automation caz i still unable to download attachment.
Hi @Majunu09
Glad to know that it worked out for you
See what u get is a varaible which is simmilar to functioning of mail message
Now to get the attachment from a varaible u can use the simmilar how u download the attachment in UiPath from mail message varaible
Check out the video
Regards
Nived N
@NIVED_NAMBIAR Hi dude,
its not outlook mail, its about .msg file. .msg file has attachment and we need to download the attachment.
I mean after the assign activitiy it becomes like mail message type itself
@NIVED_NAMBIAR Hi dude, I have no idea can you share the xaml.
@Palaniyappan Hi dude can you share an xaml file to download .msg file attachment