[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Newbie: adding attachements in email

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>



1 Answer

John Spiegel

8/14/2003 8:12:00 PM

0

Sheesh. Sorry for wasting your time. Had an extra "s" in MyMessage
(MyMesssage). Duh.
"John Spiegel" <jspiegel@c-comld.com> wrote in message
news:enpOv6oYDHA.2200@TK2MSFTNGP09.phx.gbl...
> 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>
>
>
>