<CODE>
//Get the first EntryID for the message;
ENTRYID messageEID = new ENTRYID((byte[])((MAPI33.MapiTypes.MapiBinary)inboxFolderRows[0, 0]).Value);
//MessageBox.Show(((MAPI33.MapiTypes.MapiUnicode)inboxFolderRows[0, 4]).Value);
IMessage message = null;
message = mapi.getMessage(messageEID,this.Handle);
//string test = new string[0];
bool isRead = false;
int i = 0;
//Setup the tags to PR_READ tag so after checking hte email we can set it to PR_READ = true
MAPI33.MapiTypes.Value[] readValue = new MAPI33.MapiTypes.Value[] {new MAPI33.MapiTypes.MapiBoolean(Tags.PR_READ,true) };
MAPI33.SPropProblem[] problemArray = new MAPI33.SPropProblem [] {};
//Setup information to pull from the message
Tags[] iTags = new Tags[] { Tags.PR_BODY_W, Tags.PR_SUBJECT_W, Tags.PR_SENDER_NAME_W, Tags.PR_READ};
//A array of MapiTypes.Value to save the returned information
MAPI33.MapiTypes.Value[] ivals = new MAPI33.MapiTypes.Value[] { new MAPI33.MapiTypes.MapiUnicode(Tags.PR_BODY_W, ""), new MAPI33.MapiTypes.MapiUnicode(Tags.PR_SUBJECT_W, ""), new MAPI33.MapiTypes.MapiUnicode(Tags.PR_SENDER_NAME_W, ""), new MAPI33.MapiTypes.MapiBoolean(Tags.PR_READ, isRead) };
//Get the Subject, Body, Sender, Reader tags
message.GetProps(iTags, 0, out ivals);
//MessageBox.Show(((MAPI33.MapiTypes.MapiBoolean)ivals[3]).Value.ToString());
while(((MAPI33.MapiTypes.MapiBoolean)ivals[3]).Value.ToString() == "False")
{
MessageBox.Show(((MAPI33.MapiTypes.MapiUnicode)ivals[0]).Value);
MessageBox.Show(((MAPI33.MapiTypes.MapiUnicode)ivals[1]).Value);
MessageBox.Show(((MAPI33.MapiTypes.MapiUnicode)ivals[2]).Value);
MessageBox.Show(((MAPI33.MapiTypes.MapiBoolean)ivals[3]).Value.ToString());
//MAPI33.MapiTypes.Value[] readValue = new MAPI33.MapiTypes.Value[] {new MAPI33.MapiTypes.MapiInt64(Tags.PR_Message_Flags,
Error hr = message.SetProps(readValue, out problemArray);
MessageBox.Show(hr.ToString());
hr = message.SaveChanges(__MAPI33__INTERNALS__.MAPIProp.FLAGS.ForceSave);
MessageBox.Show(hr.ToString());
//message.SaveChanges(__MAPI33__INTERNALS__.MAPIProp.FLAGS.);
//message.SetReadFlag(0);
//lstMessages.Items.Add(((MAPI33.MapiTypes.MapiUnicode)ivals[0]).Value);
i++;
messageEID = new ENTRYID((byte[])((MAPI33.MapiTypes.MapiBinary)inboxFolderRows[i, 0]).Value);
message = mapi.getMessage(messageEID,this.Handle);
message.GetProps(iTags, 0, out ivals);
}
</CODE>
When I get to the line message.SaveChanges(...) I have tried a number of different of MAPIProp.Flags i.e. 0 (no flags), Modify, etc. and hr always returns NoAccess.
I am opening my IMSGStore like this:
hr = session.OpenMsgStore(_Handle, _eID, Guid.Empty, IMAPISession.FLAGS.BestAccess, out store);
Anyone have any suggestions with how I might be able to set a IMessage to read using either setProps() then saveChanges() or any other way?
Thanks,
Andrew
Submitted via EggHeadCafe - Software Developer Portal of Choice
Outbound Link Hit Tracking With ASP.NET
http://www.eggheadcafe.com/tutorials/aspnet/d19c3d22-a40b-4012-bdd9-0c26aca44013/outbound-link-hit-trackin.aspx
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<Andrew T> wrote in message news:2009123114...@gmail.com...
Sorry for getting back to you so late; due to the fact I couldn't get this working I moved on to a different way of storing if I had read the message or not. However since this is my preferred method I have included my mapi.getMessage code here
<code>
public IMessage getMessage(ENTRYID _eID, IntPtr _Handle)
{
Error hr;
MAPI.TYPE type;
IMessage message = null;
try
{
IUnknown unkMessage;
hr = store.OpenEntry(_eID, Guid.Empty,0, out type, out unkMessage);
if (hr != Error.Success) throw new Exception("Error: " + hr.ToString());
if (type != MAPI.TYPE.Message) throw new Exception("Error: Wrong type");
if (unkMessage == null) throw new Exception("Error: Expected folder is NULL");
message = (IMessage)unkMessage;
return message;
}
catch (Exception e)
{
throw e;
}
}
</code>
Any suggestions would be greatly appreciated
Dmitry Streblechenko wrote:
How is mapi.getMessage implement?
02-Jan-10
How is mapi.getMessage implement? Are you sure it takes a window handle as
a parameter?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Previous Posts In This Thread:
On Thursday, December 31, 2009 2:36 PM
Andrew T wrote:
NO Access on Imessage.SaveChanges()
<CODE>
hr = message.SaveChanges(__MAPI33__INTERNALS__.MAPIProp.FLAGS.ForceSave);
MessageBox.Show(hr.ToString());
i++;
message = mapi.getMessage(messageEID,this.Handle);
message.GetProps(iTags, 0, out ivals);
}
</CODE>
Thanks,
Andrew
On Saturday, January 02, 2010 8:59 PM
Dmitry Streblechenko wrote:
How is mapi.getMessage implement?
How is mapi.getMessage implement? Are you sure it takes a window handle as
a parameter?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Submitted via EggHeadCafe - Software Developer Portal of Choice
Six Reasons Your Organization Should Use .NET
http://www.eggheadcafe.com/tutorials/aspnet/d59bda95-80cb-459c-a6e7-8e14b3e7f236/six-reasons-your-organiza.aspx
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<Andrew T> wrote in message news:201022956...@gmail.com...