[c#] Envoi d'un mail avec fichier joint
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:
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.
Re: [c#] Envoi d'un mail avec fichier joint
Citation:
Envoyé par macfred
Précision : fichierJoint a pour valeur : 'C:\\Documents and Settings\\fred\\My Documents\\cv.doc'
C'est bien çà le problème :) çà ressemble pas vraiment un chemin valide non :?:
[résolu][c#][ASP.NET]Envoi d'un mail avec fichier joint
lol en effet l'erreur est assez grossière.(j'ai honte)
Merci à tous