PC Review


Reply
Thread Tools Rate Thread

Attempting to create (and send) an Outlook MSG file that says sent

 
 
PromisedOyster
Guest
Posts: n/a
 
      3rd Jun 2005
We have an application that automatically sends and saves Outlook
messages. However, what I want to do is somehow get the MSG file to be
marked as 'sent' rather than 'not sent'.

Outlook.Application outlook = null;
Outlook.MailItem mailItem = null;

try
{
object o = Marshal.GetActiveObject("Outlook.Application");
outlook = o as Outlook.Application;
}
catch
{
// unable to connect to open version of Outlook. Create new instance
outlook = new Outlook.ApplicationClass();
}

Object omailItem = outlook.CreateItem(Outlook.OlItemType.olMailItem);
mailItem = omailItem as Outlook.MailItem;
mailItem.To = "(E-Mail Removed)";
mailItem.Subject = "Test email";

// The following two lines of code generates the exception:
//An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in TestEmail.exe
// Additional information: The item has been moved or deleted.

// mailItem.Send();
//mailItem.SaveAs("C:\\temp\\TestEmail.MSG",
Outlook.OlSaveAsType.olMSG);

// The following two lines of code saves and sends the email, but the
MSG file says not semt
mailItem.SaveAs("C:\\temp\\TestEmail.MSG", Outlook.OlSaveAsType.olMSG);
mailItem.Send();

What is the simplest way of getting the sent MSG (to save to file) so
it is clear that the MSG has actually been sent?


Your assistance would be greatly appreciated.

 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      3rd Jun 2005
Create the message as a post item (olPostItem) rather than olMailItem - it
will be created in the sent state, then change the MessageClass property to
"IPM.Note". You will need to change the icon as well, but you will need
Extended MAPI/CDO 1.21/Redemption for that: see
http://www.dimastr.com/redemption/faq.htm#8

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"PromisedOyster" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> We have an application that automatically sends and saves Outlook
> messages. However, what I want to do is somehow get the MSG file to be
> marked as 'sent' rather than 'not sent'.
>
> Outlook.Application outlook = null;
> Outlook.MailItem mailItem = null;
>
> try
> {
> object o = Marshal.GetActiveObject("Outlook.Application");
> outlook = o as Outlook.Application;
> }
> catch
> {
> // unable to connect to open version of Outlook. Create new instance
> outlook = new Outlook.ApplicationClass();
> }
>
> Object omailItem = outlook.CreateItem(Outlook.OlItemType.olMailItem);
> mailItem = omailItem as Outlook.MailItem;
> mailItem.To = "(E-Mail Removed)";
> mailItem.Subject = "Test email";
>
> // The following two lines of code generates the exception:
> //An unhandled exception of type
> 'System.Runtime.InteropServices.COMException' occurred in TestEmail.exe
> // Additional information: The item has been moved or deleted.
>
> // mailItem.Send();
> //mailItem.SaveAs("C:\\temp\\TestEmail.MSG",
> Outlook.OlSaveAsType.olMSG);
>
> // The following two lines of code saves and sends the email, but the
> MSG file says not semt
> mailItem.SaveAs("C:\\temp\\TestEmail.MSG", Outlook.OlSaveAsType.olMSG);
> mailItem.Send();
>
> What is the simplest way of getting the sent MSG (to save to file) so
> it is clear that the MSG has actually been sent?
>
>
> Your assistance would be greatly appreciated.
>



 
Reply With Quote
 
PromisedOyster
Guest
Posts: n/a
 
      3rd Jun 2005
Thanks Dmitry for the less than obvious solution,

I was contemplating sending the message, then getting the message from
the Sent Items folder. However, this seemed a bit klunky and error
prone. I will try out your suggestion.

Thanks


Dmitry Streblechenko wrote:
> Create the message as a post item (olPostItem) rather than olMailItem - it
> will be created in the sent state, then change the MessageClass property to
> "IPM.Note". You will need to change the icon as well, but you will need
> Extended MAPI/CDO 1.21/Redemption for that: see
> http://www.dimastr.com/redemption/faq.htm#8
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "PromisedOyster" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > We have an application that automatically sends and saves Outlook
> > messages. However, what I want to do is somehow get the MSG file to be
> > marked as 'sent' rather than 'not sent'.
> >
> > Outlook.Application outlook = null;
> > Outlook.MailItem mailItem = null;
> >
> > try
> > {
> > object o = Marshal.GetActiveObject("Outlook.Application");
> > outlook = o as Outlook.Application;
> > }
> > catch
> > {
> > // unable to connect to open version of Outlook. Create new instance
> > outlook = new Outlook.ApplicationClass();
> > }
> >
> > Object omailItem = outlook.CreateItem(Outlook.OlItemType.olMailItem);
> > mailItem = omailItem as Outlook.MailItem;
> > mailItem.To = "(E-Mail Removed)";
> > mailItem.Subject = "Test email";
> >
> > // The following two lines of code generates the exception:
> > //An unhandled exception of type
> > 'System.Runtime.InteropServices.COMException' occurred in TestEmail.exe
> > // Additional information: The item has been moved or deleted.
> >
> > // mailItem.Send();
> > //mailItem.SaveAs("C:\\temp\\TestEmail.MSG",
> > Outlook.OlSaveAsType.olMSG);
> >
> > // The following two lines of code saves and sends the email, but the
> > MSG file says not semt
> > mailItem.SaveAs("C:\\temp\\TestEmail.MSG", Outlook.OlSaveAsType.olMSG);
> > mailItem.Send();
> >
> > What is the simplest way of getting the sent MSG (to save to file) so
> > it is clear that the MSG has actually been sent?
> >
> >
> > Your assistance would be greatly appreciated.
> >


 
Reply With Quote
 
Robert Morley
Guest
Posts: n/a
 
      3rd Jun 2005
To my knowledge, your suggestion is the only way to do it without relying on
something like Redemption...it's a very annoying problem with Outlook.



Rob

"PromisedOyster" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Dmitry for the less than obvious solution,
>
> I was contemplating sending the message, then getting the message from
> the Sent Items folder. However, this seemed a bit klunky and error
> prone. I will try out your suggestion.
>
> Thanks
>
>
> Dmitry Streblechenko wrote:
>> Create the message as a post item (olPostItem) rather than olMailItem -
>> it
>> will be created in the sent state, then change the MessageClass property
>> to
>> "IPM.Note". You will need to change the icon as well, but you will need
>> Extended MAPI/CDO 1.21/Redemption for that: see
>> http://www.dimastr.com/redemption/faq.htm#8
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "PromisedOyster" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > We have an application that automatically sends and saves Outlook
>> > messages. However, what I want to do is somehow get the MSG file to be
>> > marked as 'sent' rather than 'not sent'.
>> >
>> > Outlook.Application outlook = null;
>> > Outlook.MailItem mailItem = null;
>> >
>> > try
>> > {
>> > object o = Marshal.GetActiveObject("Outlook.Application");
>> > outlook = o as Outlook.Application;
>> > }
>> > catch
>> > {
>> > // unable to connect to open version of Outlook. Create new instance
>> > outlook = new Outlook.ApplicationClass();
>> > }
>> >
>> > Object omailItem = outlook.CreateItem(Outlook.OlItemType.olMailItem);
>> > mailItem = omailItem as Outlook.MailItem;
>> > mailItem.To = "(E-Mail Removed)";
>> > mailItem.Subject = "Test email";
>> >
>> > // The following two lines of code generates the exception:
>> > //An unhandled exception of type
>> > 'System.Runtime.InteropServices.COMException' occurred in TestEmail.exe
>> > // Additional information: The item has been moved or deleted.
>> >
>> > // mailItem.Send();
>> > //mailItem.SaveAs("C:\\temp\\TestEmail.MSG",
>> > Outlook.OlSaveAsType.olMSG);
>> >
>> > // The following two lines of code saves and sends the email, but the
>> > MSG file says not semt
>> > mailItem.SaveAs("C:\\temp\\TestEmail.MSG", Outlook.OlSaveAsType.olMSG);
>> > mailItem.Send();
>> >
>> > What is the simplest way of getting the sent MSG (to save to file) so
>> > it is clear that the MSG has actually been sent?
>> >
>> >
>> > Your assistance would be greatly appreciated.
>> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Security Error Attempting to Create Outlook Object in .NET =?Utf-8?B?c2FraWVib3k=?= Microsoft VB .NET 2 4th Jan 2006 09:46 PM
Outlook 2003 attempting to send messages not in Outbox Steve Scott Microsoft Outlook Discussion 0 21st May 2005 01:36 PM
Outlook 2003 attempting to send messages.... Mark Kenny Microsoft Outlook 0 23rd Aug 2004 03:14 PM
Attempting to Send Too Large a File Judicature Microsoft Outlook 2 21st Apr 2004 01:16 AM
Outlook XP attempting to send unauthorized emails Spike \Dislocation\ Jackson Microsoft Outlook 2 13th Feb 2004 07:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 PM.