Bonjour,
Merci d'avoir repondu a mon message.
Je suis alle au lien que vous m'avez donne. Franchement j'ai pas compris grand chose puisque je suis novice dans c#.
Ce que j'ai compris que le message de securite n'existe pas dans la version Outlook 2000.
Donc j'ai choisi d'utilise ce dernier, mais a l'execution de mon code je recois l'erreur qui dit "failed to query Outlook._Application..." Pourtant j'ai ajouter les references de l'objet Outlook et Office a mes reference.
Comment resoudre ce Probleme ?
Voici le code que j'ai utilise et dit moi ce qui manque et ou je dois l'ajouter
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace emailtest1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btn1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btn1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btn1
//
this.btn1.Location = new System.Drawing.Point(104, 192);
this.btn1.Name = "btn1";
this.btn1.TabIndex = 0;
this.btn1.Text = "button1";
this.btn1.Click += new System.EventHandler(this.btn1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btn1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btn1_Click(object sender, System.EventArgs e)
{
try
{
Outlook._Application objOutlook = new Outlook.ApplicationClass();
Outlook.NameSpace objNS = objOutlook.GetNamespace("MAPI");
// objNS.Logon ("exchtest","net",false,true);
Outlook.MailItem objMail = (Outlook.MailItem) objOutlook.CreateItem(Outlook.OlItemType.olMailItem);
objMail.To = "moi@moi.com";
objMail.Subject = "new email";
objMail.Body = "I am your new email message";
objMail.Save();
objMail.Send();
}
// Simple error handler.
catch (Exception ex)
{
MessageBox.Show(ex.Message);
// Console.WriteLine("{0} Exception caught: ", ex);
}
//Default return value.
return ;
}
}
}
MERIC BEAUCOUP
creanova