none
Sending an e-mail through exchange server RRS feed

  • Question

  • Hi,

    I developed a plugin for outlook 2003 using visual studio 2005 tools for office and the c# language.

    The target machine, where the plugin is installed, is connected to an exchange server.

     

    I get an error when I try when the program try to send an e_mail message (I am using the Send() method defined in the

    Microsoft.Office.Interop.Outlook.MailItem package)

     

    System.Runtime.InteropServices.COMException was unhandled by user code
      Message="La fenêtre est désactivée, impossible d'envoyer. Vérifiez votre code."
      Source="Microsoft Office Outlook"
      ErrorCode=-1214119927
      StackTrace:
           at Microsoft.Office.Interop.Outlook._MailItem.Send()
           at AASPlugin.AASForm.saveEmailToFolderAndSend(MAPIFolder destination) in D:\Microsoft Visual Studio 8\projects\AASPlugin\AASPlugin\AASForm.Designer.cs:line 200
           at AASPlugin.AASForm.button1_Click(Object sender, EventArgs e) in D:\Microsoft Visual Studio 8\projects\AASPlugin\AASPlugin\AASForm.cs:line 25
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

     

     

    Do you know something about this error ?

    This plugin works on a machine that doesn't use exchange, is there another method to use instead of the one I used ?

     

    Many Thanks,

    Regards.

     

     


     

    Thursday, February 28, 2008 12:55 AM

Answers

  • If your goal is to file the sent message in a specific folder, that's not the way to do it. The copy will not have any of the details of when the item was sent or with what account. Instead, try setting the SaveSentMessageFolder property to the destination folder.

    Friday, February 29, 2008 12:06 AM
    Moderator

All replies

  • Before determining that the Exchange connection is related to the problem, I would test with another mail profile on the same machine, using a POP3 or IMAP4 account instead of an Exchange account. It would probably also help if you posted the code snippet that creates and sends the email message. Are you verifying that all recipents are resolved before you try to send?

    Thursday, February 28, 2008 2:49 AM
    Moderator
  • Hi,

    Thank you for helping !

     

    This is the peace of code that generates the error I posted last time:

     

     

    public void saveEmailToFolderAndSend(Outlook.MAPIFolder destination)

    {

    Outlook.MailItem currentMailCopy = currentMail.Copy() as Outlook.MailItem;

    if (destination != null)

    {

    currentMailCopy.Move(destination);

    currentMail.Send();

    }

    }

     

     

     

    the currentMail is not a null object, it corresponds to the current mail created by the user.

    The move method is excuted correctly.

    But the send method is the one that generates the exception.

     

    Thanks,

    Regards.

    Thursday, February 28, 2008 11:54 PM
  • If your goal is to file the sent message in a specific folder, that's not the way to do it. The copy will not have any of the details of when the item was sent or with what account. Instead, try setting the SaveSentMessageFolder property to the destination folder.

    Friday, February 29, 2008 12:06 AM
    Moderator