How to print out a ,msg file in memo type

Hi all, I am new to Uipath and have limited knowledge in programming, is it possible to print out a .msg file directly? I could not find any packages to do that. I need to print out the mail for record not only text, but also pictures and etc.
Actually even converting .msg to .doc before printing it is fine. Thank you all for your help in advance.

Hi @leo.xu,

Welcome to Uipath Community :grinning:

Please find the below useful link

Regards,
Omkar P

Check this link below, @leo.xu

Hope this may help you :slight_smile:

1 Like

Thanks @Reddy_Paluri, but I actually want to convert the file from .msg to .doc/.pdf.

Hi @Manish540 Thank you for your reply, but i am sorry that i really don’t understand how to apply this in uipath studio. Is it possible to share the package/.xaml ? Thanks!

You may try the following code to print whole message

Dim objOutlook As microsoft.Office.Interop.Outlook.Application
Dim objMsg As microsoft.Office.Interop.Outlook._MailItem

objOutlook = New microsoft.Office.Interop.Outlook.Application
objMsg = CType(objOutlook.CreateItemFromTemplate(io.Directory.GetCurrentDirectory + "\msg.msg"), _MailItem)

objMsg.Printout

Or try the following code to print first page only
(based on Print First Page of an Email - VBOffice)

Dim objOutlook As microsoft.Office.Interop.Outlook.Application
Dim objMsg As microsoft.Office.Interop.Outlook.MailItem
Dim objWord As microsoft.Office.Interop.Word.Application
Dim objWordDoc As microsoft.Office.Interop.Word.Document
Dim objOutlookDoc As microsoft.Office.Interop.Word.Document

objOutlook = New microsoft.Office.Interop.Outlook.Application
objMsg = CType(objOutlook.CreateItemFromTemplate(io.Directory.GetCurrentDirectory + "\sample.msg"), MailItem)

objWord = New microsoft.Office.Interop.Word.Application
objWordDoc = objWord.Documents.Add()
objOutlookDoc = CType(objMsg.GetInspector.WordEditor,microsoft.Office.Interop.Word.Document)

objOutlookDoc.Range.Copy
objWordDoc.Range.Paste

objWordDoc.PrintOut(Range:=microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintFromTo, From:="1", To:="1")

here is the XAML example
PrintMsg.xaml (12.0 KB)

Cheers

2 Likes

Thank you @J0ska, I will try it out asap!

Hi @J0ska It works, thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.