C
cbukeo via OfficeKB.com
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);
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);