Closed trienow closed 2 years ago
Update: I found that setting a specific Icon, that doesn't get displayed (such as MessageIconIndex.UnreadMail
) will prevent this from happening.
Since it seems to me like an Outlook issue, I'm closing this issue.
Nice to see that you got it solved.
Just curious, for what are you using MSGKit? In what kind of system? I originaly made it because someone wanted to store MSG files in an archive system instead of EML files.
It's interesting that your use-case for MsgKit is almost entirely different from mine.
Basically, the company I work for uses direct SMTP and emails through Outlook. In many cases, direct SMTP email-templates suffice, where we just fill the appropriate placeholders and send it off.
However, in other cases, an email is built by the system with all relevant information such as customer number, name, attachments, etc. and shown in Outlook. This, for example, gives sales people, a chance to add a more personal message / question / greeting if they know the customer well. Outlook Interops have been great for this, until the last couple of years. I had to add a try-catch and then try-again-loop around every Interop command because they will often fail randomly.
Using MsgKit, I create a msg
or an oft
, if the default signature should be added, and let Outlook open the file by running it. Writing an msg
/oft
writer had been on my to-do list for quite some time, but I was very reluctant to find your library. Thanks again :)
Nice that it suited you needs, it was not easy to write a library that can produce MSG files because however the MSG format is well documented it is still very complex. Just set one property wrong and you can't open the file anymore in Outlook. It took me a while to figure out all the properties so that Outlook would be happy and show the MSG files like it was created by Outlook itself.
Sorry to reopen this issue, but my "fix" only works for oft
s when setting DraftMode
to false
.
This got me thinking and digging a bit in this project's source code, until I found this bit here in Email.cs: https://github.com/Sicos1977/MsgKit/blob/3d963e9051f0bbeaf895f9466d3aecfe9d83d6e4/MsgKit/Email.cs#L489-L493
What this seems to do is forcibly overwrite my icon, which I set (or none) and add the draft icon if I activate draft mode. Is this intentional?
Is there a solution or workaround for this please? I'm creating a draft .oft file with an attachment which opens in Outlook ready for the user to add a message and send.
However when sent, the draft icon appears in the sent items and also in the recipient's inbox unfortunately.
Don't know if it will work (never tried it) but you can override the IconIndex with your own value
Just a side-note: It works if the Draft
-Property is set to false
. Otherwise, it doesn't work, as IconIndex
gets overridden when saving the email.
I decided to clone the repo (thanks again for providing the source) and just remove Line 492 (see my previous comment). Outlook will add the draft icon automatically, which is why I'm not certain why the line was added in the first place.
Never thought of that it gets overridden. I will change the code so that it does not override the icon if it is set manually.
Just released a new nuget package version 2.5.0 with the fix in it.
Excellent, thank you both! In 2.5.0 I was able to manually set the icon to be MessageIconIndex.UnreadMail to stop the draft icon from showing
Thanks Sicos :)
Issue
After sending, emails created with MsgKit show a draft icon in Outlook in the inbox of the recipient. Interestingly enough, it doesn't open as a draft, but as a normal email (as one would expect).
This is the code I used to generate the email:
Things I've tried
oft
, instead of anmsg
.If you have any other Ideas, I'd be glad to hear them. Thanks in advance! Otherwise, the library works great!