Quelqu'un peut-il trier le code suivant pour faire l'ajout d'une pièce jointe à un travail de courrier électronique s'il vous plaît.Ajouter une pièce jointe à l'email
Merci
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="ISO-8859-1" Debug="true" %>
<% @Import Namespace="System.Web.Mail" %>
<% @Import Namespace="IO" %>
<script language="vb" runat="server">
Sub btnSendEmail_Click(sender as Object, e as EventArgs)
Dim objMM as New MailMessage()
objMM.To = "[email protected]"
objMM.From = "[email protected]"
objMM.BodyFormat = MailFormat.HTML
objMM.Priority = MailPriority.Normal
objMM.Subject = "Attachment test"
objMM.Body = "There should be an attachment with this email"
objMM.Attachments.Add(new MailAttachment("myimage.jpg"))
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMM)
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Button runat="server" id="btnSendEmail" Text="Send email" OnClick="btnSendEmail_Click" />
</form>
</body>
</html>
+1 Bonne prise - Je n'ai même pas repéré ça ... – PhilPursglove
Merci pour ça ... je suis nouveau à .net alors des choses comme ça sont très appréciées. – Tom
OK ... il semblerait donc que prendre ce conseil crée toutes sortes d'autres erreurs avec les parties TO, FROM, BodyFormat, Attachment et SMTP du code ... quelqu'un peut-il me diriger dans la bonne direction pour corriger ces erreurs? nouveaux problèmes? – Tom