Link to home
Start Free TrialLog in
Avatar of mannevenu
mannevenu

asked on

Sending email to Inbox

Iam sendind email(s) with an Image(Image is an html view) from asp.net using system.net.mail by click in button, Iam takiingEmail Id's taking from Database.
When iam debugging from server,It is working perfectly.But when iam working through internet(in other system) it is giving an Exception  "Cannot get IIS pickup directory"

Please give me the solution.Thanks in advance......
string ToName=dtSelect.Rows[i][1].ToString();
                    string ToEmailID = dtSelect.Rows[i][2].ToString();
                    MailMessage mail = new MailMessage();
                    mail.To.Add(ToEmailID);
                    mail.Priority = MailPriority.High;
                    mail.From = new MailAddress("info@isitech.edu.in","ISiTech");
                    mail.Subject = "ISiTech BRIDGE Program";
                    string Body = "<b>Dear "+ToName+" !!!</b><br><img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 ><br> For More Details  www.isitech.edu.in";
                    AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
                    LinkedResource imagelink = new LinkedResource(Server.MapPath(".") + @"\bridge.jpg", "image/jpeg");
                    imagelink.ContentId = "imageId";
                    imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
                    htmlView.LinkedResources.Add(imagelink);
                    mail.AlternateViews.Add(htmlView);
                    SmtpClient smtp = new SmtpClient("Here I gave System IP Address", 25);
                    smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
                    smtp.Send(mail);

Open in new window

Avatar of Melih SARICA
Melih SARICA
Flag of Türkiye image

why to use method pivkupDirectoryFromIIS  ?

and the reason is u got the worksererror is permissions to access that directory..

While ur debugging i guess u have  administrator previligies.. but on product system ur app is running with networkservice account.. give network service account read and write permissions to inetpub\mailroot directory..

ASKER CERTIFIED SOLUTION
Avatar of Rahul Goel
Rahul Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mannevenu
mannevenu

ASKER

Hi Rahu Ketu patal,

I gave the path.But iam getting the same exception.
Is there another way?