shlvy Posted October 18, 2004 Posted October 18, 2004 Hi I want to attach html file to my email page. The problem is that i got an error: 'Attachments' is not a member of 'Mail' The error is in the line: mail.Attachments.Add(attachment) Why is that? Thank's. Quote
Administrators PlausiblyDamp Posted October 18, 2004 Administrators Posted October 18, 2004 Where is mail defined? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
shlvy Posted October 20, 2004 Author Posted October 20, 2004 Hi In the top of the page i wrote: <%@ Import NameSpace="System.Web.Mail" %> . Thank's. Quote
Jeff B Posted October 20, 2004 Posted October 20, 2004 This Works For Me This works for me. Imports System.Web.Mail . . . 'Create an instance of the MailMessage class Dim mail AsNew MailMessage 'Set the To field mail.To = "someone@someisp.com" 'Set the From field mail.From = "someone@someisp.com" 'Set the CC field mail.From = "someone@someisp.com" 'Set the Bcc field mail.Bcc= "someone@someisp.com" 'Send the email in HTML format mail.BodyFormat = MailFormat.Html 'Set the priority - options are High, Low, and Normal mail.Priority = MailPriority.Normal 'Set the subject mail.Subject = "Some Subject" 'Set the body mail.Body = "<html><bodyThis is an HTML email with an attachment.</body></html>" 'Set attachments mail.Attachments.Add(New MailAttachment("C:\somefile.html")) 'In order to specify a different SMTP mail server to use to send the message, 'set the SmtpServer property: '************************************* 'SmtpMail.SmtpServer = emailServerName '************************************* 'Be careful, though. Since this is a static property, 'changing this value in one ASP.NET Web page will affect 'all ASP.NET Web pages using sending emails via the SmtpMail object. 'That is, if in one ASP.NET Web page you set the SmtpServer 'property to myMailServer, and then, in another ASP.NET Web page, 'do not specify the SmtpServer property, intending to use 'the default SMTP server, myMailServer will be used instead. 'For that reason, you should probably always specify 'the SmtpServer property - if you want to use 'the default SMTP server, simply do: '*********************** SmtpMail.SmtpServer = "127.0.0.1" 'Now, to send the message, use the Send method of the SmtpMail class SmtpMail.Send(mail) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.