sunitc's WebLog

  • System.Web.Mail

    It has been a long time since I have written a component that sends email.  In the .NET world, sending email has been made very easy and all the objects are defind under the System.Web.Mail namespace.  System.Web.Mail is a simple wrapper for the COM objects in cdonts.dll and cdosys.dll.

    Following is a code snipped for sending email with an attachment:

       MailMessage MailMsg= new MailMessage();
       MailMsg.To = "
    sunitc@microsoft.com";
       MailMsg.From = "
    SWM_Test@sunitc.com";
       MailMsg.Subject = "[info] System.Wed.Mail Test Message";
       MailMsg.Body = "System.Web.Mail Body of the Message";
       // Create the attachment : enter the correct path to the file that is to be attached
       MailAttachment attachment = new MailAttachment("mypath\test.txt"); //create the attachment
       MailMsg.Attachments.Add( attachment );
       // Put in your real smtp server below
       SmtpMail.SmtpServer = "mySmtpServer";
       SmtpMail.Send( MailMsg);

  • May you live in Interesting times

     

    After months of unrelenting pressure from my big brother (Vinit Carpenter), I have decided to start blogging. :-) 

    I am an App Dev consultant and work for Microsoft Consulting Services.  I primarily work with Biztalk Server 2004 and .NET related technologies.  I recently moved to Miami from Santa Monica, CA and am now focused on public sector related projects.

    In the coming days, weeks and months, I will have many interesting technical and non technical tit-bits to share and will do so via my blog.

This Blog

Syndication

Tags

No tags have been created or used yet.

Archives


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker