| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
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 -- Greg Ewing [MVP] http://www.citidc.com/ |
|
||
|
||||
|
|
|
| |
|
Dmitry Streblechenko
Guest
Posts: n/a
|
Try Application.CreateItemFromTemplate instead. To set HTML, use
MailItem.HTMLBody property. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message news:%(E-Mail Removed)... > 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 > > -- > Greg Ewing [MVP] > http://www.citidc.com/ > > > > > |
|
||
|
||||
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
Dmitry, those fields won't be read only if I create from a template? So I
can do something like this: MailItem mi = (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); mi.ReceivedTime = "11/2/2002"; //or some other valid time? mi.SenderAddress = "WhateverIWant"; Thanks a lot -- Greg Ewing [MVP] http://www.citidc.com/ "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message news:e0ma2#(E-Mail Removed)... > Try Application.CreateItemFromTemplate instead. To set HTML, use > MailItem.HTMLBody property. > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > news:%(E-Mail Removed)... > > 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 > > > > -- > > Greg Ewing [MVP] > > http://www.citidc.com/ > > > > > > > > > > > > |
|
||
|
||||
|
Dmitry Streblechenko
Guest
Posts: n/a
|
You would need to use Extended MAPI/CDO 1.21/Redemption to change these
fields. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message news:%(E-Mail Removed)... > Dmitry, those fields won't be read only if I create from a template? So I > can do something like this: > > MailItem mi = > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > mi.SenderAddress = "WhateverIWant"; > > Thanks a lot > > -- > Greg Ewing [MVP] > http://www.citidc.com/ > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > news:e0ma2#(E-Mail Removed)... > > Try Application.CreateItemFromTemplate instead. To set HTML, use > > MailItem.HTMLBody property. > > > > Dmitry Streblechenko (MVP) > > http://www.dimastr.com/ > > OutlookSpy - Outlook, CDO > > and MAPI Developer Tool > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > news:%(E-Mail Removed)... > > > 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 > > > > > > -- > > > Greg Ewing [MVP] > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
I tried the following two sets of code but I still get an error telling me
that SenderName is readonly. Am I using the wrong Redemption object? Redemption.MessageItem mi = (MessageItem)app.CreateItemFromTemplate("blogPost.oft", null); mi.SenderName = author; and Redemption.SafeMailItem mi = new SafeMailItemClass(); mi.Item = (MailItem)app.CreateItemFromTemplate("blogPost.oft", null); mi.SenderName = author; I get the same error for the Sender, ReceivedTime, and SentOn properties. -- Greg Ewing [MVP] http://www.citidc.com "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > You would need to use Extended MAPI/CDO 1.21/Redemption to change these > fields. > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > news:%(E-Mail Removed)... > > Dmitry, those fields won't be read only if I create from a template? So I > > can do something like this: > > > > MailItem mi = > > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > > mi.SenderAddress = "WhateverIWant"; > > > > Thanks a lot > > > > -- > > Greg Ewing [MVP] > > http://www.citidc.com/ > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > news:e0ma2#(E-Mail Removed)... > > > Try Application.CreateItemFromTemplate instead. To set HTML, use > > > MailItem.HTMLBody property. > > > > > > Dmitry Streblechenko (MVP) > > > http://www.dimastr.com/ > > > OutlookSpy - Outlook, CDO > > > and MAPI Developer Tool > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > news:%(E-Mail Removed)... > > > > 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 > > > > > > > > -- > > > > Greg Ewing [MVP] > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Dmitry Streblechenko
Guest
Posts: n/a
|
1. SenderName is more thanjust one string property, it is half adozen of
PR_SENDER_PROPERTIES 2. You only dim and cast the variable as Redemption.MessageItem, but you still get the same old Outlook.MailItem from CreateItemFromTemplate 3. Try the following code instead: MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem); set SafeItem = CreateObject("Redemption.SafeMailItem") SafeItem.Item = mi SafeItem.Import("blogPost.oft", 3) mi.Save mi.Save however reset SentOn and Received properties, so an even better solution would be MailItem mi = (MailItem)blog.Items.Add(OlItemType.olPostItem); //this way the message is create in the "sent" state mi.Save; strEntryID = mi.EntryID; mi = NULL; Utils = CreateObject("Redemption.MAPIUtils"); sItem = Utils.GetItemFromID(strEntryID); sItem.Import("blogPost.oft", 3); sItem.Save; Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message news:%(E-Mail Removed)... > I tried the following two sets of code but I still get an error telling me > that SenderName is readonly. Am I using the wrong Redemption object? > > Redemption.MessageItem mi = > (MessageItem)app.CreateItemFromTemplate("blogPost.oft", null); > mi.SenderName = author; > > and > > Redemption.SafeMailItem mi = new SafeMailItemClass(); > mi.Item = (MailItem)app.CreateItemFromTemplate("blogPost.oft", null); > mi.SenderName = author; > > I get the same error for the Sender, ReceivedTime, and SentOn properties. > > -- > Greg Ewing [MVP] > http://www.citidc.com > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... > > You would need to use Extended MAPI/CDO 1.21/Redemption to change these > > fields. > > > > Dmitry Streblechenko (MVP) > > http://www.dimastr.com/ > > OutlookSpy - Outlook, CDO > > and MAPI Developer Tool > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > news:%(E-Mail Removed)... > > > Dmitry, those fields won't be read only if I create from a template? So > I > > > can do something like this: > > > > > > MailItem mi = > > > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > > > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > > > mi.SenderAddress = "WhateverIWant"; > > > > > > Thanks a lot > > > > > > -- > > > Greg Ewing [MVP] > > > http://www.citidc.com/ > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > news:e0ma2#(E-Mail Removed)... > > > > Try Application.CreateItemFromTemplate instead. To set HTML, use > > > > MailItem.HTMLBody property. > > > > > > > > Dmitry Streblechenko (MVP) > > > > http://www.dimastr.com/ > > > > OutlookSpy - Outlook, CDO > > > > and MAPI Developer Tool > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > news:%(E-Mail Removed)... > > > > > 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 > > > > > > > > > > -- > > > > > Greg Ewing [MVP] > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
OK, how would I use either of those to set the ReceivedTime?
I changed this : MailItem mi = (MailItem)blog.Items.Add(OlItemType.olPostItem); to : PostItem pi = (PostItem)blog.Items.Add(OlItemType.olPostItem); because the former threw an invalid cast exception. Now, PostItem doesn't include ReceivedTime so I can't set it. If I change the above to reference to MailItem all the properties are there but ReadOnly. I must be missing something, think you could give me some sample code that will do this: MailItem.ReceivedTime = DateTime.Now? I'm at a loss. Thanks again for all of your help so far. -- Greg Ewing [MVP] http://www.citidc.com "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)... > 1. SenderName is more thanjust one string property, it is half adozen of > PR_SENDER_PROPERTIES > 2. You only dim and cast the variable as Redemption.MessageItem, but you > still get the same old Outlook.MailItem from CreateItemFromTemplate > 3. Try the following code instead: > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem); > set SafeItem = CreateObject("Redemption.SafeMailItem") > SafeItem.Item = mi > SafeItem.Import("blogPost.oft", 3) > mi.Save > > mi.Save however reset SentOn and Received properties, so an even better > solution would be > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olPostItem); //this way > the message is create in the "sent" state > mi.Save; > strEntryID = mi.EntryID; > mi = NULL; > Utils = CreateObject("Redemption.MAPIUtils"); > sItem = Utils.GetItemFromID(strEntryID); > sItem.Import("blogPost.oft", 3); > sItem.Save; > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > news:%(E-Mail Removed)... > > I tried the following two sets of code but I still get an error telling me > > that SenderName is readonly. Am I using the wrong Redemption object? > > > > Redemption.MessageItem mi = > > (MessageItem)app.CreateItemFromTemplate("blogPost.oft", null); > > mi.SenderName = author; > > > > and > > > > Redemption.SafeMailItem mi = new SafeMailItemClass(); > > mi.Item = (MailItem)app.CreateItemFromTemplate("blogPost.oft", null); > > mi.SenderName = author; > > > > I get the same error for the Sender, ReceivedTime, and SentOn properties. > > > > -- > > Greg Ewing [MVP] > > http://www.citidc.com > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > news:(E-Mail Removed)... > > > You would need to use Extended MAPI/CDO 1.21/Redemption to change these > > > fields. > > > > > > Dmitry Streblechenko (MVP) > > > http://www.dimastr.com/ > > > OutlookSpy - Outlook, CDO > > > and MAPI Developer Tool > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > news:%(E-Mail Removed)... > > > > Dmitry, those fields won't be read only if I create from a template? > So > > I > > > > can do something like this: > > > > > > > > MailItem mi = > > > > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > > > > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > > > > mi.SenderAddress = "WhateverIWant"; > > > > > > > > Thanks a lot > > > > > > > > -- > > > > Greg Ewing [MVP] > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > > news:e0ma2#(E-Mail Removed)... > > > > > Try Application.CreateItemFromTemplate instead. To set HTML, use > > > > > MailItem.HTMLBody property. > > > > > > > > > > Dmitry Streblechenko (MVP) > > > > > http://www.dimastr.com/ > > > > > OutlookSpy - Outlook, CDO > > > > > and MAPI Developer Tool > > > > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > > news:%(E-Mail Removed)... > > > > > > 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 > > > > > > > > > > > > -- > > > > > > Greg Ewing [MVP] > > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
Just to make sure you know what I mean, what if I wanted to do this:
MailItem.ReceivedTime = DateTime.MinValue How would I do that? -- Greg Ewing [MVP] http://www.citidc.com "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message news:#(E-Mail Removed)... > OK, how would I use either of those to set the ReceivedTime? > I changed this : MailItem mi = > (MailItem)blog.Items.Add(OlItemType.olPostItem); > to : PostItem pi = (PostItem)blog.Items.Add(OlItemType.olPostItem); > because the former threw an invalid cast exception. Now, PostItem doesn't > include ReceivedTime so I can't set it. If I change the above to reference > to MailItem all the properties are there but ReadOnly. I must be missing > something, think you could give me some sample code that will do this: > MailItem.ReceivedTime = DateTime.Now? I'm at a loss. > > Thanks again for all of your help so far. > > -- > Greg Ewing [MVP] > http://www.citidc.com > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > news:#(E-Mail Removed)... > > 1. SenderName is more thanjust one string property, it is half adozen of > > PR_SENDER_PROPERTIES > > 2. You only dim and cast the variable as Redemption.MessageItem, but you > > still get the same old Outlook.MailItem from CreateItemFromTemplate > > 3. Try the following code instead: > > > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem); > > set SafeItem = CreateObject("Redemption.SafeMailItem") > > SafeItem.Item = mi > > SafeItem.Import("blogPost.oft", 3) > > mi.Save > > > > mi.Save however reset SentOn and Received properties, so an even better > > solution would be > > > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olPostItem); //this way > > the message is create in the "sent" state > > mi.Save; > > strEntryID = mi.EntryID; > > mi = NULL; > > Utils = CreateObject("Redemption.MAPIUtils"); > > sItem = Utils.GetItemFromID(strEntryID); > > sItem.Import("blogPost.oft", 3); > > sItem.Save; > > > > Dmitry Streblechenko (MVP) > > http://www.dimastr.com/ > > OutlookSpy - Outlook, CDO > > and MAPI Developer Tool > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > > news:%(E-Mail Removed)... > > > I tried the following two sets of code but I still get an error telling > me > > > that SenderName is readonly. Am I using the wrong Redemption object? > > > > > > Redemption.MessageItem mi = > > > (MessageItem)app.CreateItemFromTemplate("blogPost.oft", null); > > > mi.SenderName = author; > > > > > > and > > > > > > Redemption.SafeMailItem mi = new SafeMailItemClass(); > > > mi.Item = (MailItem)app.CreateItemFromTemplate("blogPost.oft", null); > > > mi.SenderName = author; > > > > > > I get the same error for the Sender, ReceivedTime, and SentOn > properties. > > > > > > -- > > > Greg Ewing [MVP] > > > http://www.citidc.com > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > news:(E-Mail Removed)... > > > > You would need to use Extended MAPI/CDO 1.21/Redemption to change > these > > > > fields. > > > > > > > > Dmitry Streblechenko (MVP) > > > > http://www.dimastr.com/ > > > > OutlookSpy - Outlook, CDO > > > > and MAPI Developer Tool > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > news:%(E-Mail Removed)... > > > > > Dmitry, those fields won't be read only if I create from a template? > > So > > > I > > > > > can do something like this: > > > > > > > > > > MailItem mi = > > > > > > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > > > > > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > > > > > mi.SenderAddress = "WhateverIWant"; > > > > > > > > > > Thanks a lot > > > > > > > > > > -- > > > > > Greg Ewing [MVP] > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > > > news:e0ma2#(E-Mail Removed)... > > > > > > Try Application.CreateItemFromTemplate instead. To set HTML, use > > > > > > MailItem.HTMLBody property. > > > > > > > > > > > > Dmitry Streblechenko (MVP) > > > > > > http://www.dimastr.com/ > > > > > > OutlookSpy - Outlook, CDO > > > > > > and MAPI Developer Tool > > > > > > > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > > > news:%(E-Mail Removed)... > > > > > > > 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 > > > > > > > > > > > > > > -- > > > > > > > Greg Ewing [MVP] > > > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
Well, I got past this with the MAPIUtils class. Now I just have to figure
out how to make the From address show up correctly. Right now it shows up as the currently logged in user (me) in the message list pane and as the actual author when viewing the message. Here's the code. pi is a PostItem. Redemption.MAPIUtils utils = new Redemption.MAPIUtils(); int PrReceivedTime = 235274304; //&0E060040; utils.HrSetOneProp(pi, PrReceivedTime, dt, true); -- Greg Ewing [MVP] http://www.citidc.com "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message news:#(E-Mail Removed)... > Just to make sure you know what I mean, what if I wanted to do this: > > MailItem.ReceivedTime = DateTime.MinValue > > How would I do that? > > -- > Greg Ewing [MVP] > http://www.citidc.com > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > news:#(E-Mail Removed)... > > OK, how would I use either of those to set the ReceivedTime? > > I changed this : MailItem mi = > > (MailItem)blog.Items.Add(OlItemType.olPostItem); > > to : PostItem pi = (PostItem)blog.Items.Add(OlItemType.olPostItem); > > because the former threw an invalid cast exception. Now, PostItem doesn't > > include ReceivedTime so I can't set it. If I change the above to > reference > > to MailItem all the properties are there but ReadOnly. I must be missing > > something, think you could give me some sample code that will do this: > > MailItem.ReceivedTime = DateTime.Now? I'm at a loss. > > > > Thanks again for all of your help so far. > > > > -- > > Greg Ewing [MVP] > > http://www.citidc.com > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > news:#(E-Mail Removed)... > > > 1. SenderName is more thanjust one string property, it is half adozen of > > > PR_SENDER_PROPERTIES > > > 2. You only dim and cast the variable as Redemption.MessageItem, but you > > > still get the same old Outlook.MailItem from CreateItemFromTemplate > > > 3. Try the following code instead: > > > > > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem); > > > set SafeItem = CreateObject("Redemption.SafeMailItem") > > > SafeItem.Item = mi > > > SafeItem.Import("blogPost.oft", 3) > > > mi.Save > > > > > > mi.Save however reset SentOn and Received properties, so an even better > > > solution would be > > > > > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olPostItem); //this > way > > > the message is create in the "sent" state > > > mi.Save; > > > strEntryID = mi.EntryID; > > > mi = NULL; > > > Utils = CreateObject("Redemption.MAPIUtils"); > > > sItem = Utils.GetItemFromID(strEntryID); > > > sItem.Import("blogPost.oft", 3); > > > sItem.Save; > > > > > > Dmitry Streblechenko (MVP) > > > http://www.dimastr.com/ > > > OutlookSpy - Outlook, CDO > > > and MAPI Developer Tool > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > > > news:%(E-Mail Removed)... > > > > I tried the following two sets of code but I still get an error > telling > > me > > > > that SenderName is readonly. Am I using the wrong Redemption object? > > > > > > > > Redemption.MessageItem mi = > > > > (MessageItem)app.CreateItemFromTemplate("blogPost.oft", null); > > > > mi.SenderName = author; > > > > > > > > and > > > > > > > > Redemption.SafeMailItem mi = new SafeMailItemClass(); > > > > mi.Item = (MailItem)app.CreateItemFromTemplate("blogPost.oft", null); > > > > mi.SenderName = author; > > > > > > > > I get the same error for the Sender, ReceivedTime, and SentOn > > properties. > > > > > > > > -- > > > > Greg Ewing [MVP] > > > > http://www.citidc.com > > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > > news:(E-Mail Removed)... > > > > > You would need to use Extended MAPI/CDO 1.21/Redemption to change > > these > > > > > fields. > > > > > > > > > > Dmitry Streblechenko (MVP) > > > > > http://www.dimastr.com/ > > > > > OutlookSpy - Outlook, CDO > > > > > and MAPI Developer Tool > > > > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > > news:%(E-Mail Removed)... > > > > > > Dmitry, those fields won't be read only if I create from a > template? > > > So > > > > I > > > > > > can do something like this: > > > > > > > > > > > > MailItem mi = > > > > > > > > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > > > > > > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > > > > > > mi.SenderAddress = "WhateverIWant"; > > > > > > > > > > > > Thanks a lot > > > > > > > > > > > > -- > > > > > > Greg Ewing [MVP] > > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > > > > news:e0ma2#(E-Mail Removed)... > > > > > > > Try Application.CreateItemFromTemplate instead. To set HTML, use > > > > > > > MailItem.HTMLBody property. > > > > > > > > > > > > > > Dmitry Streblechenko (MVP) > > > > > > > http://www.dimastr.com/ > > > > > > > OutlookSpy - Outlook, CDO > > > > > > > and MAPI Developer Tool > > > > > > > > > > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > > > > news:%(E-Mail Removed)... > > > > > > > > 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 > > > > > > > > > > > > > > > > -- > > > > > > > > Greg Ewing [MVP] > > > > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
Greg Ewing [MVP]
Guest
Posts: n/a
|
OK, last post for this thread for now. I fixed my last problem with
int PrSentRepresentingName = 4325406; Thanks for the great objects Dmitry. -- Greg Ewing [MVP] http://www.citidc.com "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message news:(E-Mail Removed)... > Well, I got past this with the MAPIUtils class. Now I just have to figure > out how to make the From address show up correctly. Right now it shows up > as the currently logged in user (me) in the message list pane and as the > actual author when viewing the message. > > Here's the code. pi is a PostItem. > > Redemption.MAPIUtils utils = new Redemption.MAPIUtils(); > int PrReceivedTime = 235274304; //&0E060040; > utils.HrSetOneProp(pi, PrReceivedTime, dt, true); > > -- > Greg Ewing [MVP] > http://www.citidc.com > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > news:#(E-Mail Removed)... > > Just to make sure you know what I mean, what if I wanted to do this: > > > > MailItem.ReceivedTime = DateTime.MinValue > > > > How would I do that? > > > > -- > > Greg Ewing [MVP] > > http://www.citidc.com > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > > news:#(E-Mail Removed)... > > > OK, how would I use either of those to set the ReceivedTime? > > > I changed this : MailItem mi = > > > (MailItem)blog.Items.Add(OlItemType.olPostItem); > > > to : PostItem pi = (PostItem)blog.Items.Add(OlItemType.olPostItem); > > > because the former threw an invalid cast exception. Now, PostItem > doesn't > > > include ReceivedTime so I can't set it. If I change the above to > > reference > > > to MailItem all the properties are there but ReadOnly. I must be > missing > > > something, think you could give me some sample code that will do this: > > > MailItem.ReceivedTime = DateTime.Now? I'm at a loss. > > > > > > Thanks again for all of your help so far. > > > > > > -- > > > Greg Ewing [MVP] > > > http://www.citidc.com > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > news:#(E-Mail Removed)... > > > > 1. SenderName is more thanjust one string property, it is half adozen > of > > > > PR_SENDER_PROPERTIES > > > > 2. You only dim and cast the variable as Redemption.MessageItem, but > you > > > > still get the same old Outlook.MailItem from CreateItemFromTemplate > > > > 3. Try the following code instead: > > > > > > > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olMailItem); > > > > set SafeItem = CreateObject("Redemption.SafeMailItem") > > > > SafeItem.Item = mi > > > > SafeItem.Import("blogPost.oft", 3) > > > > mi.Save > > > > > > > > mi.Save however reset SentOn and Received properties, so an even > better > > > > solution would be > > > > > > > > MailItem mi = (MailItem)blog.Items.Add(OlItemType.olPostItem); //this > > way > > > > the message is create in the "sent" state > > > > mi.Save; > > > > strEntryID = mi.EntryID; > > > > mi = NULL; > > > > Utils = CreateObject("Redemption.MAPIUtils"); > > > > sItem = Utils.GetItemFromID(strEntryID); > > > > sItem.Import("blogPost.oft", 3); > > > > sItem.Save; > > > > > > > > Dmitry Streblechenko (MVP) > > > > http://www.dimastr.com/ > > > > OutlookSpy - Outlook, CDO > > > > and MAPI Developer Tool > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message > > > > news:%(E-Mail Removed)... > > > > > I tried the following two sets of code but I still get an error > > telling > > > me > > > > > that SenderName is readonly. Am I using the wrong Redemption > object? > > > > > > > > > > Redemption.MessageItem mi = > > > > > (MessageItem)app.CreateItemFromTemplate("blogPost.oft", null); > > > > > mi.SenderName = author; > > > > > > > > > > and > > > > > > > > > > Redemption.SafeMailItem mi = new SafeMailItemClass(); > > > > > mi.Item = (MailItem)app.CreateItemFromTemplate("blogPost.oft", > null); > > > > > mi.SenderName = author; > > > > > > > > > > I get the same error for the Sender, ReceivedTime, and SentOn > > > properties. > > > > > > > > > > -- > > > > > Greg Ewing [MVP] > > > > > http://www.citidc.com > > > > > > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > > > news:(E-Mail Removed)... > > > > > > You would need to use Extended MAPI/CDO 1.21/Redemption to change > > > these > > > > > > fields. > > > > > > > > > > > > Dmitry Streblechenko (MVP) > > > > > > http://www.dimastr.com/ > > > > > > OutlookSpy - Outlook, CDO > > > > > > and MAPI Developer Tool > > > > > > > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in message > > > > > > news:%(E-Mail Removed)... > > > > > > > Dmitry, those fields won't be read only if I create from a > > template? > > > > So > > > > > I > > > > > > > can do something like this: > > > > > > > > > > > > > > MailItem mi = > > > > > > > > > > (MailItem)CreateItemFromTemplate(@"c:\pathtotemplate\mytemplate.oft"); > > > > > > > mi.ReceivedTime = "11/2/2002"; //or some other valid time? > > > > > > > mi.SenderAddress = "WhateverIWant"; > > > > > > > > > > > > > > Thanks a lot > > > > > > > > > > > > > > -- > > > > > > > Greg Ewing [MVP] > > > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message > > > > > > > news:e0ma2#(E-Mail Removed)... > > > > > > > > Try Application.CreateItemFromTemplate instead. To set HTML, > use > > > > > > > > MailItem.HTMLBody property. > > > > > > > > > > > > > > > > Dmitry Streblechenko (MVP) > > > > > > > > http://www.dimastr.com/ > > > > > > > > OutlookSpy - Outlook, CDO > > > > > > > > and MAPI Developer Tool > > > > > > > > > > > > > > > > > > > > > > > > "Greg Ewing [MVP]" <gewing@_NO_SPAM_citidc.com> wrote in > message > > > > > > > > news:%(E-Mail Removed)... > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > -- > > > > > > > > > Greg Ewing [MVP] > > > > > > > > > http://www.citidc.com/ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create a macro to create excel line graph with coloured pointers anddata lables | anuj datta | Microsoft Excel Charting | 1 | 30th Sep 2009 04:04 PM |
| how to create an auto reply rule/macro that wont create a new mess | squalltheonly | Microsoft Outlook Discussion | 4 | 15th Nov 2008 04:03 PM |
| reset button, create excel, import table, send e-mail, create back-up | matthew nance | Microsoft Access | 0 | 27th Jul 2004 06:52 PM |
| Read Bitmap and create Method to Create Image at runtime | Mark Johnson | Microsoft Dot NET Framework | 1 | 28th Nov 2003 08:26 PM |
| Create user on win2k domain does not create mailbox on ex2k server | Jeff Howard | Microsoft Windows 2000 | 0 | 1st Oct 2003 12:21 AM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |




