Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / August 2003

Tip: Looking for answers? Try searching our database.

Newbie:  adding attachements in email

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Spiegel - 14 Aug 2003 19:12 GMT
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
John Spiegel - 14 Aug 2003 21:11 GMT
Sheesh.  Sorry for wasting your time.  Had an extra "s" in MyMessage
(MyMesssage).  Duh.
> Hey All,
>
[quoted text clipped - 58 lines]
> </body>
> </html

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.