try
{
MailMessage mail = new MailMessage();
mail.To.Add("imran3may@gmail.com");
mail.To.Add("shi01715@yahoo.com");
mail.From = new MailAddress("shishir64092@gmail.com");
mail.Subject = "Send Email by asp.net code using google or gmail smtp server";
string Body = "Hi, I am testing Email function in asp.net" +
" using google or gmail smtp server"+
" and next time I will send you a document from my .aspx file";
mail.Body = Body;
Attachment at = new Attachment("D:\\Text");
mail.Attachments.Add(at);
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("localhost",25);
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential
("shishir64092@gmail.com", "abcdef");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true; ;
smtp.Send(mail);
Label1.Text = "Mail Send...";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
My Web.Config file is ::
="1.0"<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="PickupDirectoryFromIis">
<network defaultCredentials="true" host="localhost" port="25"/>
</smtp>
</mailSettings>
</system.net>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation></system.web></configuration>
Than tell me where is my prob?
The Error Message is: Could not find file 'D:\Text'.