Outlook is randomly deleting attachment(s) from mailitem during item send event - c#

I'm currently experiencing some strange behavior when sending e-mails using Outlook (Office 365 Pro Plus).
Our software can generate e-mails and show a new mail compose to the user with attachments which they selected from our software. (We use both Redemption from our software as Outlook Object Model using an Outlook Add-in Express add-in)
Below you can find the code for generating the e-mail using Redemption:
bool createEmail = false;
RDOSession session = new RDOSession();
session.Logon("", "", false, false, null, false);
RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderDrafts);
RDOMail mail = folder.Items.Add("IPM.Note");
... Code for selecting receivers (returns string with emailadresses) ...
... Code for converting word documents to PDF / Adding the attachments to the mailitem ...
RDOUserProperty userProp = mail.UserProperties.Add("DMS_AttachmentCount", rdoUserPropertyType.olInteger, false, false);
userProp.Value = mail.Attachments.Count;
mail.Display();
I noticed that I'm not using
mail.Save();
Could that be the issue?
When we show the user the generated e-mail all attachments are in place and the user is able to open the attachments.
So far so good...
Here comes the problem:
On sending the e-mail, sometimes (i mean really sometimes) some of the
attachments are deleted from the e-mail. When the user goes to it's
sent items and selects the e-mail, some of the attachments are
deleted.
Since this occurs randomly, I'm not able to debug this issue.
What have I tried already:
Turn off ESET Nod32 and all of it's e-mail components
Disabled Office Secured Mode
Exclude certain file extensions from being scanned.
Checked for third party add-ins, so far only the list below is installed
The rest of the add-ins are default by Outlook
My question(s):
Is there somebody out there that has experienced the same problem?
How can I determine what happens inside the Item Send event?
What else can I turn off or apply on the server that might prevent this issue from happening?
Thanks.

Related

Outlook vsto - properties handling

i have a problem with MailItem properties in a Outlook VSTO. I add some custom properties to a previously exported .msg mail with e.g. redemption in the following way:
SafeMailItem smi = new SafeMailItem {
Item = mailItem
};
int propertyId = smi.GetIDsFromNames(PROPERTY_GUID, "anyID");
smi.Fields[propertyId] = propertyString;
This property is removed and i cant find it again if i click on sending the mail. I checked this with Outlook Spy and before i send the mail the property is available but after i click on send (and e.g. cancel the send) the property is gone.
I also tried to call MailItem.Save() (at any time) but it has no effect apart from the fact that the .msg file includes the mail edits :). The same behavior is given if i use MailItem.PropertyAccessor directly.
Can anybody explain me why the properties are removed and how to fix this issue?
Thanks a lot for support
Outlook version: 16.0.0.13530 (64-bit); Visual Studio Professional 2019 16.8.4

How to capture sent items with Outlook addin across multiple accounts?

I have built an Outlook 2010 Addin using C#. I created an Inspector wrapper and I am using it to capture when an item is added to the Sent Items folder.
I then capture some details about that item and do something with it.
It's been working great, but I've recently come across someone who has multiple email accounts in Outlook. My addin seems only to capture the items from 1 of the sent item folders.
sentfolder = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
sentitems = sentfolder.Items;
sentitems.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(sentitems_ItemAdd);
_wrappedInspectors = new Dictionary<Guid, InspectorWrapper>();
_inspectors = Globals.ThisAddIn.Application.Inspectors;
_inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(WrapInspector);
Obviously I just need to iterate through the folders for the different accounts and identify each of the sent items folders but I am unsure how to achieve that.
If the user has multiple email accounts, the Session.Stores or Session.Accounts should provide access to the other shared mailboxes they use.
See this related SO post on how to get access to shared mailboxes.

Setting Outlook signature for multiple accounts

I am in the process of writing an application that sets a signature based on pre-acquired data for each Microsoft Outlook account(a user may have multiple Outlook accounts for various purposes).
I am able to set a signature for the default account, but I have yet to find how to set a signature for each Outlook account individually. I have done a lot of my own research and poked around the Microsoft.Office.Interop objects without much luck.
Is there a way to achieve this?
To choose the Outlook profile programmatically, you just use
Microsoft.Office.Interop.Outlook.Application App =
new Microsoft.Office.Interop.Outlook.Application();
NameSpace mapi = App.GetNamespace("MAPI");
mapi.Logon(profileName);
obviously setting the profileName to what is shown in the dropdown list upon starting Outlook (if you do not set a default profile in the control panel email settings).
This however is problematic in a number of ways since Outlook does not support multiple sessions even though the MAPI logon does:
http://msdn.microsoft.com/en-us/library/bb219914(v=office.12).aspx
Meaning: if Outlook is already running, you can even set NewSession to true, but it won't help. It will give you the currently-logged-in profile regardless of what name you set. If you have an Outlook zombie (I got that while testing, check with task manager), i.e. an Outlook without an UI showing up, the problem is the same.
If you can ensure Outlook does not run while doing stuff with signatures, you should be fine though.

Bypass "Program is trying to access ... Outlook" Dialog Box

I'm facing one issue while writing Office Outlook 2007 Add-In, I'm accessing the email contents of email currently being sent by capturing Send event. Everything works fine but when accessing the subject/body of the email through Outlook.MailItem object (in C#), it prompts a dialog box to allow/deny this program to access. Can anyone help how to bypass this dialog box and allow the program to access MailItem ?
Thanks
Safiullah
I don think it is possible, MSFT has placed this alert box to avoid an illegal mail box access by malicious program... However, following guys claim that they can by-pass:
http://www.ablebits.com/programming-outlook-security/index.php

C# opening up a blank email with an attachment using Exchange

I'm new to the world of C# programming but was hoping someone could help me out.
I'm trying to use C# to open up a blank email in Outlook with a specified attachment.
In other words, open the email, the TO: and SUBJECT: fields are blank but the email has an attachment that is specified in my code. I want my user to be able to modify the email and send to whatever users s/he specifies. I know for sure that we have Exchange....so any ideas?
There are a number of way you can do this.
Create an Outlook addin that opens a new mail with the attachment you want via say a new toolbar button.
Do the same in Outlook VBA macro ..
Also you could create a new form with the attachment in it already and then just us that form.(but the attachment will be hard coded etc.)
Does the attachment change ? or is it the same one evey time ? what outlook version are you using ? What are you programing capabilties ?
76mel
I don't think exchange will help you much, you need to work with outlook on the users machine. You can add a reference to the Outlook interop assemblies, should be in the Com tab of your add references dialog.
Here's some links to jump start you.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.aspx
http://www.microeye.com/resources/res_tech_vsnet.htm
Good Luck!

Categories

Resources