I've got the below python code to extract the HTML body from a .msg file and I want to do the same in a desktop flutter app. Is this possible to do using the win32 package? Or is there a simpler way to get the HTML from a .msg file?
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\messageTest.msg")
I've tried adapting the idispatch example (see below) but I can't get it to work. I've kept the same Dispatcher class but changed Shell.Application to Outlook.Application. This returns 'WindowsException (Error 0x80040154: Class not registered)'. Not sure if this is the right way to approach it? Also not sure if I need to call GetNamespace first or if I can just use OpenSharedItem?
final hr = OleInitialize(nullptr);
if (FAILED(hr)) throw WindowsException(hr);
final dispatcher = Dispatcher.fromProgID('Outlook.Application');
final method = dispatcher.getDispId('GetNamespace');
final paramString = BSTR.fromString('MAPI');
final parameter = calloc<VARIANT>();
parameter
..ref.vt = VARENUM.VT_BSTR
..ref.bstrVal = paramString.ptr;
final parameters = calloc<DISPPARAMS>()
..ref.cArgs = 1
..ref.rgvarg = parameter;
dispatcher.invokeMethod(method, parameters);