Posts 1 - 10 of 11
First | Prev. | 1 2 | Next | Last
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
Hello,
I tried to manipulate when the inspector window is open, tried using the ADX NewInspector, I'm trying to programmatically suppress certain inspector window from being open.
I have the following 2 functions bind to the ADX events:
private void adxOutlookEvents_NewInspector(object sender, object _inspector, string folderName)
{
logger.Debug("adxOutlookEvents_NewInspector");
try
{
string entryId = string.Empty;
Inspector inspector = (_inspector as Inspector);
object obj = inspector.CurrentItem;
if (obj != null && obj is MailItem)
{
MailItem item = obj as MailItem;
item.Open += new ItemEvents_10_OpenEventHandler(SupressMailItem_Open);
}
Marshal.ReleaseComObject(obj);
Marshal.ReleaseComObject(inspector);
}
catch (System.Exception ex)
{
logger.Ex(ex);
}
}
private void adxOutlookEvents_InspectorActivate(object sender, object _inspector, string folderName)
{
logger.Debug("adxOutlookEvents_InspectorActivate");
try
{
string entryId = string.Empty;
Inspector inspector = (_inspector as Inspector);
...
I purposely forced the item to close, but the InspectorActivate still got fired and when it tries to access the inspector, it throws an exception.
So, 2 questions...
1) Is there a way to suppress the InspectorActivate inside NewInspector?
2) Is the exception caused by me freeing the inspector inside NewInspector? Or is caused by there is no active inspector being opened since I suppressed it?
If the 2nd question is the answer (because no inspector is active after I suppressed it) then why it InspectorActivate still gets fired? Should it fires AFTER NewInspector is finished? I have a feeling that these 2 events are being fired at the same time regardless of the outcome in NewInspector. |
|
Posted 22 Nov, 2016 14:36:12
|
|
Top
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
Err... It looks like I didn't really suppressed the inspector window.. It was the exception that stopped the inspector window from opening...
So i guess i'd like to know how to prevent Inspector window from opening inside NewInspector event. |
|
Posted 22 Nov, 2016 14:43:10
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
|
Posted 23 Nov, 2016 05:25:35
|
|
Top
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
How can I change the flow so that it would display a different item in the ProcessRead?
I've followed the sample project and intercepted the ProcessOpen, I basically created a copy of the MailItem internally and modified the content of the copy. Now I want to display the modified copy in the ProcessRead (i'm guessing this is the spot to display it?)
Ultimately, what i'm trying to do is to either avoid the "Do you want to save the changes?" dialog that pops up or make the modified copy as read only so that when they close it, no save prompt will presents to the user. |
|
Posted 23 Nov, 2016 10:46:41
|
|
Top
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
Hum... I think I might be able to do it by using ProcessClose or maybe ProcessWrite event hook...
However, I'm pretty sure the Close event comes after the inspector is being closed... |
|
Posted 23 Nov, 2016 11:18:06
|
|
Top
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
Any idea why I am getting:
COM object that has been separated from its underlying RCW cannot be used.
For the ItemObj inside the event handler class? I didn't ReleaseComObject on the mail object since I need to connect to it.
private void adxOutlookEvents_NewInspector(object sender, object _inspector, string folderName)
{
Inspector inspector = (_inspector as Inspector);
object obj = inspector.CurrentItem;
if (obj != null && obj is MailItem)
{
MailItem mail = obj as MailItem;
if (mail != null)
{
if (mail.MessageClass.ToUpper().Contains("TEST"))
{
logger.Debug("Attaching to test mail item");
if (testMailHandler.IsConnected)
testMailHandler.RemoveConnection();
testMailHandler.ConnectTo(obj, true);
}
else
{
Marshal.ReleaseComObject(mail);
}
}
}
}
In the ProcessOpen...
public override void ProcessOpen(ADXCancelEventArgs e)
{
logger.Debug("ProcessOpen");
try
{
string entryId = (ItemObj as MailItem).EntryID; <== dying here
logger.Debug(entryId);
}
catch (System.Exception ex)
{
logger.Ex(ex);
}
e.Cancel = true;
}
|
|
Posted 23 Nov, 2016 11:24:46
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
Hello Eric,
developer_cp writes:
How can I change the flow so that it would display a different item in the ProcessRead?
ProcessRead doesn't relate to this. You can cancel opening the current item, create another item, save it (note it saves to the Drafts folder) and call MailItem.Open on it.
developer_cp writes:
Any idea why I am getting: COM object that has been separated from its underlying RCW cannot be used.
You release that object somewhere. Note that calling ADXOutlookItemEvents.RemoveConnection release the COM object if you passed true to the second parameter of the ADXOutlookItemEvents.ConnectTo() method.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 24 Nov, 2016 07:17:34
|
|
Top
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
Is there a way to open the saved item as a regular email? Right now when i open the newly created item, it opened as editable mail.
I tried saving it into different location and is the same thing. (ex: c:\temp\test.msg)
I've also tried to set "Sent" to true, but it still opens as editable email. How can I make it read only? |
|
Posted 25 Nov, 2016 09:31:07
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
|
Posted 25 Nov, 2016 09:48:45
|
|
Top
|
|
developer_cp
Posts: 48
Joined: 2016-10-28
|
Update:
I end up doing the following to get what I wanted, hope this might help someone:
- Create a folder (ex: temp) under Inbox
- Add a hook to InspectorActivate
- On InspectorActivate, attach an ADXOutlookItemEvents object to the MailItem
- In the ProcessOpen of ADXOutlookItemEvents, suppress the open event and COPY the MailItem into temp folder.
- Do whatever you need to do with the copy and display that copy at the end of the ProcessOpen
Regarding to ADXOutlookItemEvents object, refer to the above suggestions by Andrei Smolin. |
|
Posted 28 Nov, 2016 17:17:01
|
|
Top
|
|
Posts 1 - 10 of 11
First | Prev. | 1 2 | Next | Last
|