Bonjour,

j'essaye d'envoyer un mail en ASP.NET avec fichier joint. (Sans le fichier joint, il n'y a pas d'erreur, le mail est bien envoyé)
Voilà l'erreur que je rencontre :

Pièce jointe 'C:\\Documents and Settings\\fred\\My Documents\\cv.doc' non valide.

Et voici le code de ma procédure :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
public static void EnvoyerCandidature(string expediteur, string detailCandidature, string fichierJoint)
  {
   MailAttachment fichierDoc = new MailAttachment(fichierJoint);
 
   MailMessage objMail = new MailMessage();
   objMail.Subject = "Candidature emploi";
   objMail.To = System.Configuration.ConfigurationSettings.AppSettings["email_recrutement"];
   objMail.From = expediteur;
   objMail.Body = detailCandidature;
   objMail.BodyFormat = MailFormat.Html;
   objMail.Attachments.Add(fichierDoc);
   SmtpMail.SmtpServer = System.Configuration.ConfigurationSettings.AppSettings["serveurSmtp"];
   try
   {
    SmtpMail.Send(objMail);
   }
   catch (Exception ex)
   {
    throw ex;
   }
  }
Précision : fichierJoint a pour valeur : 'C:\\Documents and Settings\\fred\\My Documents\\cv.doc'

Merci d'avance pour votre aide.