John Spiegel
8/14/2003 6:12:00 PM
Hey All,
I'm trying to follow some emailing examples from an ASPX page. I'm pretty
much there except can't seem to attach a file. When it reaches the line:
MyMesssage.Attachments.Add(MyAttachment);
the page gives a compilation error: The type or namespace name 'MyMesssage'
could not be found (are you missing a using directive or an assembly
reference?)
Any ideas on what I'm missing?
TIA,
John
<%@ Page Language="C#" %>
<%@ import Namespace="System.Web.Mail" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
for (int i=0; i < 10; i++)
{
// Build a MailMessage
MailMessage MyMessage = new MailMessage();
MyMessage.From = "jspiegel@c-comld.com";
MyMessage.To = "jspiegel@c-comld.com";
MyMessage.Subject = "MailServer added";
MyMessage.BodyFormat = MailFormat.Text;
MyMessage.Body = "narf";
SmtpMail.SmtpServer = "localhost";
MailAttachment MyAttachment = new MailAttachment(@"C:\Temp\Temp.txt");
MyMesssage.Attachments.Add(MyAttachment);
/* From the examples:
char[] delim = new char[] {','};
foreach (string sSubstr in sAttach.Split(delim))
{
MailAttachment MyAttachment = new MailAttachment(sSubstr);
MyMail.Attachments.Add(MyAttachment);
}
MailAttachment.Filename = @"C:\MyDir\Temp.txt";
*/
SmtpMail.Send(MyMessage);
}
}
</script>
<html>
<head>
</head>
<body style="FONT: 10pt verdana">
<form runat="server">
<asp:Label id="lblMsg" runat="Server"></asp:Label>
</form>
</body>
</html>