Hello everyone, I’m doing upgrades to working processes from legacy to windows. in 1 process I use a library from the market that converts my eml to msg file. Now I need such activity in windows project. cause this one is not supported or any other workaround you people know.
Thanks in advance!
EDIT: Furthermore I’ve tried the Save Email to msg Activity from ’ ADROSONIC - Save Email’ Library. But I get error "MailMessage to Msg: Method not found: ‘Void MsgKit.Email…ctor(MsgKit.Sender, System.String, Boolean, Boolean)’
try thsi code…A little chatgpt and few error modifications landed her…
two prereqs 1. Outlook to be present and installed. 2. Default app to open eml should be set to outlook
Dim emlFilePath As String = "C:\Users\gorth\Downloads\sample.eml"
Dim msgOutputPath As String = "C:\Users\gorth\Downloads\test_sample_message.msg"
Dim outlookApp As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application()
Dim mailItem As Microsoft.Office.Interop.Outlook.MailItem = Nothing
' Use ShellExecute to open .eml file in Outlook (instead of command-line args)
Dim process As System.Diagnostics.Process = New System.Diagnostics.Process()
process.StartInfo.FileName = emlFilePath ' Open file directly using system defaults
process.StartInfo.UseShellExecute = True
process.Start()
' Wait dynamically for the email to open
Dim maxWaitTime As Integer = 15000 ' Max wait time in milliseconds (15 seconds)
Dim waitedTime As Integer = 0
Do While outlookApp.ActiveInspector Is Nothing AndAlso waitedTime < maxWaitTime
System.Threading.Thread.Sleep(500) ' Check every 500ms
waitedTime += 500
Loop
' Once email is open, save it as .msg
mailItem = CType(outlookApp.ActiveInspector.CurrentItem, Microsoft.Office.Interop.Outlook.MailItem)
mailItem.SaveAs(msgOutputPath, Microsoft.Office.Interop.Outlook.OlSaveAsType.olMSG)
' Close email without prompt
mailItem.Save()
mailItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard)