Posts

Showing posts from December, 2009

Send Gmail using Dot NET

Hi, in my previous posts, I have posted how to send mail using the Java API. In this section, I would like to demonstrate on how to send mail using Dot NET. Using Dot NET, it is equally easy to send mail. In this post I would use my Dot NET application to connect with Google's outgoing mail server (Google's SMTP server) and use that to forward my mail. (In my previous post, I've demonstrated on sending mail using my own SMTP server which ran on my machine. In this scenario, it will directly put the outgoing message into the Gmail's SMTP server) You will be using mainly few Classes to get the job done. System.Net.Mail.MailMessage System.Net.NetworkCredential System.Net.Security.SmtpClient These classes will provide the basic methods to get the job done. You will also be using System.Net.Mail.MailAddress class. (Though there is a way to get the job done without actually needing this.) First of all, you need to import the namespaces. using System.

Download File using Dot Net

In this post, I will demonstrate how easy it is to download a file from a web server to your local hard drive. In most scenarios, you may browse the net using your web browser and click on a hyperlink to start a downloading of a file from a remote site. Some of you may be interested in how to download this using their application code using Dot Net. This can be very easily achieved using the WebClient class under System.Net namespace. First, import the System.Net namespace. using System.IO; The above LOC will do so. Now, create an instance of WebCleient class. WebClient client = new WebClient(); Now, call the DownloadFile method client.DownloadFile(<url>, @"<fileDestinationName>.<filetype>"); Have fun. Cheers !!!!