G
Greg Ewing [MVP]
Hi all, I'm building an Outlook application to read blogs (similar to
Newsgator) and am having some trouble getting the new items in to my folders
correctly. With the code below I get what is basically a draft message in
the folder which doesn't have the To: or ReceivedTime set correctly. One
idea I have is to write out .msg files with all of the correct information
set and then import those back in to the folder. Would that work? If it
would, does anyone have any code to write out new .msg files? I can export
an existing MailItem with SaveAs() which doesn't help since I can't set all
of the necessary properties on the MailItem before writing.
I also looked in to ExMAPI with C++ but haven't found a sample yet which
writes new messages to a folder and sets the ReceivedTime and SentTo
properties. Anyone have anything like that?
I'm using C# right now but have no problem writing parts or all in C++ if
that's necessary.
Here's the code I'm using which doesn't work. I've also tried the
Redemption objects but can't set the sender address or ReceivedTime with
those either. (unless I'm missing something)
//blog is the destination folder in Outlook
//si is an RSS item from the RSS feed
private void AddItemToFolder(Outlook.MAPIFolder blog, SyndicationItem si,
string author)
{
MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem);
mi.Subject = si.Title;
mi.Body = si.Description + Environment.NewLine + Environment.NewLine +
si.Comments;
mi.Body = mi.Body + Environment.NewLine + Environment.NewLine + si.Link;
//mi.ReceivedTime = si.PubDate; //read-only property
mi.SentOnBehalfOfName = author; //hack to make the sender's name show up
in the folder list view
mi.DeferredDeliveryTime = DateTime.Now; //si.PubDate; //doesn't set the
received time
mi.Save();
mi.Move(blog);
}
Another less important question at this point is how do I get the body to
display HTML? I tried setting the BodyFormat of the MailItem but the HTML
still just shows up in the message body as HTML, not interpreted.
Thanks a lot for any and all help!
x-posted to microsoft.public.platformsdk.mapi and
microsoft.public.outlook.program_addins
Newsgator) and am having some trouble getting the new items in to my folders
correctly. With the code below I get what is basically a draft message in
the folder which doesn't have the To: or ReceivedTime set correctly. One
idea I have is to write out .msg files with all of the correct information
set and then import those back in to the folder. Would that work? If it
would, does anyone have any code to write out new .msg files? I can export
an existing MailItem with SaveAs() which doesn't help since I can't set all
of the necessary properties on the MailItem before writing.
I also looked in to ExMAPI with C++ but haven't found a sample yet which
writes new messages to a folder and sets the ReceivedTime and SentTo
properties. Anyone have anything like that?
I'm using C# right now but have no problem writing parts or all in C++ if
that's necessary.
Here's the code I'm using which doesn't work. I've also tried the
Redemption objects but can't set the sender address or ReceivedTime with
those either. (unless I'm missing something)
//blog is the destination folder in Outlook
//si is an RSS item from the RSS feed
private void AddItemToFolder(Outlook.MAPIFolder blog, SyndicationItem si,
string author)
{
MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem);
mi.Subject = si.Title;
mi.Body = si.Description + Environment.NewLine + Environment.NewLine +
si.Comments;
mi.Body = mi.Body + Environment.NewLine + Environment.NewLine + si.Link;
//mi.ReceivedTime = si.PubDate; //read-only property
mi.SentOnBehalfOfName = author; //hack to make the sender's name show up
in the folder list view
mi.DeferredDeliveryTime = DateTime.Now; //si.PubDate; //doesn't set the
received time
mi.Save();
mi.Move(blog);
}
Another less important question at this point is how do I get the body to
display HTML? I tried setting the BodyFormat of the MailItem but the HTML
still just shows up in the message body as HTML, not interpreted.
Thanks a lot for any and all help!
x-posted to microsoft.public.platformsdk.mapi and
microsoft.public.outlook.program_addins