Mail avec piece jointe

Résolu
marliche0 Messages postés 66 Date d'inscription mardi 8 mars 2005 Statut Membre Dernière intervention 30 septembre 2008 - 16 juin 2005 à 21:12
thiosyiasar Messages postés 186 Date d'inscription lundi 11 mars 2002 Statut Membre Dernière intervention 30 novembre 2010 - 17 juin 2005 à 10:33
Bonjour, je cherche une fonction qui me permet d'envoyer un mail avec des pieces jointes, cette fonction existe-t-elle en c# ou faut-il la developper? A moins que quelqu'un ai deja vu quelque chose la dessus...

Merci d'avance

2 réponses

thiosyiasar Messages postés 186 Date d'inscription lundi 11 mars 2002 Statut Membre Dernière intervention 30 novembre 2010 3
17 juin 2005 à 10:33
Regarde un peu dans ce namespace;

System.Web.Mail;

T'as d'la chance, j'ai même un p'tit exemple



public
class HTMLMailer


{



private MailMessage _oMsg;



public HTMLMailer()


{



this._oMsg =
new MailMessage();



this._oMsg.BodyEncoding = System.Text.Encoding.ASCII;





this._oMsg.BodyFormat = System.Web.Mail.MailFormat.Html;



this._oMsg.UrlContentBase =
string.Empty;



this._oMsg.UrlContentLocation =
string.Empty;



this._oMsg.Priority = MailPriority.Normal;



}



public
string Body


{



set {
this._oMsg.Body =
value; }



get {
return
this._oMsg.Body; }


}



public
string Subject


{



set {
this._oMsg.Subject =
value; }



get {
return
this._oMsg.Subject; }


}



public
string RecipientAddress


{



set {
this._oMsg.To =
value; }



get {
return
this._oMsg.To; }


}



public
void AddAttachment(
string filePath)


{


MailAttachment oAttachment =
new MailAttachment(filePath, MailEncoding.Base64);



this._oMsg.Attachments.Add(oAttachment);


}



public
void Send()


{



string s =
this._oMsg.ToString();



this._oMsg.From = "[mailto:monmail@coucou.com monmail@coucou.com]";


SmtpMail.SmtpServer = "mail.free.fr"


SmtpMail.Send(
this._oMsg);
//Impossible d'accéder à l'objet 'CDO.Message'.


}


}

Nico
3
marliche0 Messages postés 66 Date d'inscription mardi 8 mars 2005 Statut Membre Dernière intervention 30 septembre 2008
16 juin 2005 à 21:13
je cherche la fonction en asp pardon
0
Rejoignez-nous