![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hello All,
I am developing an Outlook 2007 addin using VisualStudio 2008 and C#. My goal is to create an email inside a user created folder. I successfully create the folder and a message. However, I cannot get the message placed in the user created folder. Instead it always ends up in the default "Drafts" folder. Is there an outlook object model call that can solve this problem? My code looks like this (a bit simplified): using Outlook = Microsoft.Office.Interop.Outlook; Outlook.Folder olFolder = olParentFolder.Folders.Add("AUserFolder", OlDefaultFolders.OlDefaultFolders.olFolderInbox); Outlook.MailItem olMail = (Outlook.MailItem)olFolder.Items.Add(OlItemType. olMailItem); olMail.Subject = "Message Subject"; olMail.Body = "Message Unformatted Body"; foreach (string fromAddress in fromAddresses) { Outlook.Recipient olRecipient = olMail.Recipients.Add(fromAddress); olRecipient.Type = OlMailRecipientType.olOriginator; olRecipient.Resolve(); } foreach (string toAddress in toAddresses) { Outlook.Recipient olRecipient = olMail.Recipients.Add(fromAddress); olRecipient.Type = OlMailRecipientType.olTo; olRecipient.Resolve(); } olMail.Close(OlInspectorClose.olSave); -- Message posted via http://www.officekb.com |
#2
|
|||
|
|||
![]()
New messages are always created in Drafts. If you want to move it to the
desired folder after the message is created in Drafts you can do so. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "cbukeo via OfficeKB.com" u59160@uwe wrote in message news:a673768e8b499@uwe... Hello All, I am developing an Outlook 2007 addin using VisualStudio 2008 and C#. My goal is to create an email inside a user created folder. I successfully create the folder and a message. However, I cannot get the message placed in the user created folder. Instead it always ends up in the default "Drafts" folder. Is there an outlook object model call that can solve this problem? My code looks like this (a bit simplified): using Outlook = Microsoft.Office.Interop.Outlook; Outlook.Folder olFolder = olParentFolder.Folders.Add("AUserFolder", OlDefaultFolders.OlDefaultFolders.olFolderInbox); Outlook.MailItem olMail = (Outlook.MailItem)olFolder.Items.Add(OlItemType. olMailItem); olMail.Subject = "Message Subject"; olMail.Body = "Message Unformatted Body"; foreach (string fromAddress in fromAddresses) { Outlook.Recipient olRecipient = olMail.Recipients.Add(fromAddress); olRecipient.Type = OlMailRecipientType.olOriginator; olRecipient.Resolve(); } foreach (string toAddress in toAddresses) { Outlook.Recipient olRecipient = olMail.Recipients.Add(fromAddress); olRecipient.Type = OlMailRecipientType.olTo; olRecipient.Resolve(); } olMail.Close(OlInspectorClose.olSave); -- Message posted via http://www.officekb.com |
#3
|
|||
|
|||
![]()
Thanks! Very simple solution. Can't help but smile and wonder how come I
could not think about this? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...ddins/201004/1 |
#4
|
|||
|
|||
![]()
Ken,
Now I am able to move messages around within folders. However, the messages stay as drafts. How can I set their sent status to true? This is also causing problems if I try to set them as tasks. OOM throws an exception complaining that a draft message cannot be set as a task. Many thanks again Buke Ken Slovak - [MVP - Outlook] wrote: New messages are always created in Drafts. If you want to move it to the desired folder after the message is created in Drafts you can do so. Hello All, [quoted text clipped - 37 lines] olMail.Close(OlInspectorClose.olSave); -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...ddins/201004/1 |
#5
|
|||
|
|||
![]()
What do you mean "set a message as a task"? They are 2 different objects and
MessageClass's. If you want to create a task item create one and copy any property values from your email message item to the task that you want (such as Subject or body text, etc.). You cannot use the Outlook object model to create an item that looks sent. You can use Extended MAPI or a 3rd party library, Redemption (www.dimastr.com/redemption) to do that. You'd have to set various properties such as sender addresses and so on to the values you want as well as the Sent property before the new item you create is saved the first time. There's a code sample showing that at the Redemption Web site. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "cbukeo via OfficeKB.com" u59160@uwe wrote in message news:a6a004c1c7866@uwe... Ken, Now I am able to move messages around within folders. However, the messages stay as drafts. How can I set their sent status to true? This is also causing problems if I try to set them as tasks. OOM throws an exception complaining that a draft message cannot be set as a task. Many thanks again Buke |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create a new Outlook MailItem in an Outlook folder(not a draft) | Sanjeev | Outlook - Using Forms | 2 | March 22nd 10 10:46 AM |
Create a forwarded mailitem that has a flag but requires user to s | mkp1702 | Outlook and VBA | 1 | March 10th 08 05:44 AM |
Create and Get user-defined fields in folder | ck | Add-ins for Outlook | 10 | January 11th 08 05:02 PM |
How to create user-defined fields in Organizational Forms Library folder? | [email protected] | Add-ins for Outlook | 3 | March 15th 07 09:07 PM |
How can I create a MailItem that displays like a received MailItem ? | Clive | Outlook - Using Forms | 0 | February 27th 06 04:14 PM |