Can anyone sort out the following code to make the adding an attachment to an email work please.
Thanks
<%@ 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>