A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem getting Incoming Item in my Outlook Addin



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 6th 06, 08:53 AM posted to microsoft.public.outlook.program_addins
seby
external usenet poster
 
Posts: 1
Default Problem getting Incoming Item in my Outlook Addin

It seems there is a bug in an addin i am working on. While retrieving an incoming MailItem from outlook using this code:

Outlook::_MailItemPtr spMItem;
hr = spItems-raw_GetLast(&pDisp);
spMItem = pDisp;

the spMItem is always NULL , even though this is fired in Check New Mail event

Q1: Shouldn't GetLast be the last added item aka new Email ?
Q2: Since the same happens with OnAddItem, OnItemChanged ...

OnItemChangedParameter ( IDispatch iDisp)
{ // cast to _MailItemPtr
spMItem = iDisp; // spMItem is NULL on incoming email

how can one get the New item (incoming message) using this type of code (ATL/C++) in a spMItem
Just looking for a simple reliable solution
Thank you
~SB

Ads
  #2  
Old May 6th 06, 07:44 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Problem getting Incoming Item in my Outlook Addin

Most likely that means the message is something other than MailItem. Note
that you can have objects rather than MailItem in your Inbox, e.g. NDRs,
meeting requests, etc.
Try to read the Class property first using late binding (all Outlook objects
support it). Regular mail items will have Class = 43.
Did you try to explicilty call iDisp.QueryInterface(...) to see if you
really get E_NOINTERFACE error?
Also note that Items.GetLast is not guarantee is not guaranteed to return
the last added item, so using Items.ItemAdd event on the Inbox or
Application.NewMailEx (Outlook 2003, passes the entry id which can be used
to call Namespace.GetItemFromID) could be a much better alternative.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"seby" wrote in message
...
It seems there is a bug in an addin i am working on. While retrieving an
incoming MailItem from outlook using this code:

Outlook::_MailItemPtr spMItem;
hr = spItems-raw_GetLast(&pDisp);
spMItem = pDisp;

the spMItem is always NULL , even though this is fired in Check New Mail
event

Q1: Shouldn't GetLast be the last added item aka new Email ?
Q2: Since the same happens with OnAddItem, OnItemChanged ...

OnItemChangedParameter ( IDispatch iDisp)
{ // cast to _MailItemPtr
spMItem = iDisp; // spMItem is NULL on incoming email

how can one get the New item (incoming message) using this type of code
(ATL/C++) in a spMItem
Just looking for a simple reliable solution
Thank you
~SB


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A different problem with Outlook Addin Ram Add-ins for Outlook 1 April 24th 06 03:31 PM
Outlook 2003 Strips Carriage Returns off of Incoming Mail When Viewing the Item John Smith Outlook - General Queries 3 April 18th 06 02:48 AM
Problem with setting Outlook item userproperties KeithXP Outlook and VBA 4 April 14th 06 03:01 PM
OCX problem in VB Outlook AddIn Rui Oliveira Add-ins for Outlook 0 March 31st 06 05:42 PM
unload COM addin problem David Cebrian Add-ins for Outlook 3 February 9th 06 11:26 AM


All times are GMT +1. The time now is 05:58 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.