Gents, Can we modify this code to include the attachment via a web form? <%@ Page Language="VB" %> <%@ Import Namespace="System.Net.Mail" %> <script runat="server"> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim strFrom = "[email protected]" Dim strTo = "[email protected]" Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo)) MailMsg.BodyEncoding = Encoding.Default MailMsg.Subject = "Subject" MailMsg.Body = "This is a sample message" MailMsg.Priority = MailPriority.High MailMsg.IsBodyHtml = True 'Smtpclient to send the mail message Dim SmtpMail As New SmtpClient SmtpMail.Host = "localhost" SmtpMail.Send(MailMsg) lblMessage.Text = "Mail Sent" End Sub </script> <html> <body> <form runat="server"> <asp:Label id="lblMessage" runat="server"></asp:Label> </form> </body> </html> Thanks.
You just need to add this code to send an attachment: Dim Attach As New Attachment("PathtoFile") MailMsg.Attachments.Add(Attach) You can use the Server Path found in your Control Panel as a starting point. It maps to the root of your hosting account and you can add additional directories if needed.
I managed to do it on the same day of the post but I did not update you guys. Anyways, thanks indeed.