C# et securite dans outlook 2003

Résolu
creanova2000 Messages postés 39 Date d'inscription jeudi 31 juillet 2003 Statut Membre Dernière intervention 21 septembre 2006 - 28 janv. 2005 à 19:23
cs_sarv Messages postés 2 Date d'inscription jeudi 23 janvier 2003 Statut Membre Dernière intervention 29 mars 2006 - 29 mars 2006 à 14:40
Bonjour,

J'utilise le code suivant pour envoyer un email a deux distinataires. En utilisant Outlook 2003

Le probleme c'est quand le programme envoi les email Outlook jette un mesage de securite.
J'ai mis le niveau de securite de Outlook au niveua le plus bas, mais cela ne resoud pas le probleme.

Comment faire Pour se debarasser de ce message de securite et de confirmation que outlook 2003 donne ?

Voici le code :


using System;


//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following line.


using Outlook = Microsoft.Office.Interop.Outlook;


namespace outlooktest


{



/// <summary>



/// Summary description for Class1.



/// </summary>



class Class1


{



/// <summary>



/// The main entry point for the application.



/// </summary>


[STAThread]



static
void Main(
string[] args)


{



//



// TODO: Add code to start application here



//



try


{



// Create the Outlook application by using inline initialization.


Outlook.Application oApp =
new Outlook.Application();



//Create the new message by using the simplest approach.


Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);



//Add a recipient.



// TODO: Change the following recipient where appropriate.


Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("ss@ss.com.com");


Outlook.Recipient oRecip2 = (Outlook.Recipient)oMsg.Recipients.Add("moi@moi.com");


oRecip.Resolve();



//Set the basic properties.


oMsg.Subject = "TEST";


oMsg.Body = "C'est un test";





//Add an attachment.



// TODO: change file path where appropriate


String sSource = "C:\\test.txt";


String sDisplayName = "MyFirstAttachment";



int iPosition = (
int)oMsg.Body.Length + 1;



int iAttachType = (
int)Outlook.OlAttachmentType.olByValue;


Outlook.Attachment oAttach = oMsg.Attachments.Add(sSource,iAttachType,iPosition,sDisplayName);



// If you want to, display the message.


oMsg.Display(
false);
//modal



//Send the message.


oMsg.Save();


oMsg.Send();



//Explicitly release objects.


oRecip =
null;


oAttach =
null;


oMsg =
null;


oApp =
null;


}



// Simple error handler.



catch (Exception e)


{


Console.WriteLine("{0} Exception caught: ", e);


}



//Default return value.



return ;


}


}


}

Merci beaucoup de votre aide

Creanova.

4 réponses

creanova2000 Messages postés 39 Date d'inscription jeudi 31 juillet 2003 Statut Membre Dernière intervention 21 septembre 2006 5
2 févr. 2005 à 18:32
MERCI,

Le probleme a ete resolu par la suppression d'une clef de registre.

merci
a la prochaine.
3
TheSaib Messages postés 2367 Date d'inscription mardi 17 avril 2001 Statut Membre Dernière intervention 26 décembre 2007 23
31 janv. 2005 à 13:21
http://www.outlookcode.com/d/sec.htm

::|The S@ib|::
MVP C#.NET
0
creanova2000 Messages postés 39 Date d'inscription jeudi 31 juillet 2003 Statut Membre Dernière intervention 21 septembre 2006 5
1 févr. 2005 à 18:12
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 description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btn1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;





public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();


//
// TODO: Add any constructor code after InitializeComponent call
//
}


///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
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


///
/// The main entry point for the application.
///
[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 = "[mailto:moi@moi.com 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
0
cs_sarv Messages postés 2 Date d'inscription jeudi 23 janvier 2003 Statut Membre Dernière intervention 29 mars 2006
29 mars 2006 à 14:40
Quelle est la manip à faire dans la base de registre ???
0
Rejoignez-nous