J'ai une page qui a le contrôle fileupload, sur la soumission du formulaire, lorsque le contrôle fileupload a un fichier, le fichier est envoyé par pièce jointe dans un courrier et fonctionne absulutly bien, mais quand le contrôle fileupload n'a pas de fichier, le fichier ATT00006.dat est automatiquement envoyé par e-mail.ATT00006.dat fichier attaché automatiquement dans la pièce jointe
URL de référence: http://nextech.pk/Enquiry.aspx?Enq=cu
Merci d'avance pour toute aide
Modifier - Code:
hpf = fup1.PostedFile;
String toEmail = "[email protected]";
String fromEmail = "[email protected]";
MailMessage objMail = new MailMessage(fromEmail, toEmail);
objMail.IsBodyHtml = true;
StringBuilder MailBody = new StringBuilder();
MailBody.Append("<html><head></head><body> <br>");
MailBody.Append("<br>" + "An enquiry is filed <br><br>");
MailBody.Append("<strong><u>Enquirer Information</u></strong>" + "<br><br>");
MailBody.Append("<strong>Contact Name:</strong>	" + txtFirstName.Text + "<br>");
MailBody.Append("<strong>Email:</strong>			 " + txtEmail.Text + "<br>");
MailBody.Append("<strong>Institute:</strong>		 " + txtInstitute.Text + "<br>");
MailBody.Append("<strong>Phone #:</strong>		 " + txtPhone.Text + "<br>");
MailBody.Append("<br><strong>Description:</strong><br>         " + txtEnquiry.Text + "<br>");
if (hpf != null)
{
MailBody.Append("<br>" + "This email also contains an attachment:- <Strong>(" + hpf.FileName + ")</Strong><br>");
}
MailBody.Append("</body></html>");
objMail.Body = MailBody.ToString();
if (hpf != null)
{
System.IO.Stream inputStream = hpf.InputStream;
String fileName = hpf.FileName;
Attachment attach = new Attachment(inputStream, fileName);
objMail.Attachments.Add(attach);
}
SmtpClient SmtpClnt = new SmtpClient();
SmtpClnt.Send(objMail);
J'ai posté du code, s'il vous plaît vérifier, merci –
Quand il n'y a pas de fichier joint. Voyez-vous le texte "Ce message contient également une pièce jointe" avec la pièce jointe ATT00006.dat. – Shoban
oui .. c'est le texte .... Cet e-mail contient également une pièce jointe: -() –