Creating an item

G

Guest

This seems trivial, but I just can't seem to figure out this problem. I
retrieve a sub-folder of the inbox which I created earlier. Then I get its
Items, and then add an Item to the Items list using the Add method. But when
I go into Outlook the sub-folder is still empty. Here's the code:

Outlook.Items subItems = subFolder.Items;
testItem = (Outlook._MailItem) subItems.Add(Outlook.OlItemType.olMailItem);
testItem.HTMLBody = "<HTML><H2>The body of this message will appear in
HTML.</H2><BODY>Enter the message text here. </BODY></HTML>";

If I call Display() on the item, it will display, and if I call Save() it
will save the item, but to the Drafts folder. How do I get it to appear in
my sub folder?

Background info: I'm writing C# code in VS .NET and programming for Outlook
2000 and later.

Thanks
 
S

Sue Mosher [MVP-Outlook]

An unsent MailItem always saves to the Drafts folder, regardless of what
folder you try to create it in. You can try to move it from Drafts to
another folder after you save it, but I know some people have encountered
problems with that.

Why are you using a MailItem anyway, instead of a PostItem?
 
G

Guest

Thanks, I saved it and then moved it to my sub folder, it worked great!

The reason I am using a MailItem is that I am retrieving HTML from a web
service and I want to display it in the reading pane. So I figured I'd put
it in the HTMLBody property of a MailItem. If there's a cleaner way to do it
tho, I'd be happy to hear it!

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top