Unable to Sent Email with Attachment using SMTP Client. Asp.net MVC C# -
i tried send email using smtp client using .net mvc pdf attachment (in memory attachment), not working on live server.
please note: able sent email attachment localhost. when deployed on live server (hosted on iis) not working. same method working without attachment on live server.
i getting following exception:
system.net.mail.smtpexception: failure sending mail. system.net.webexception: remote name not resolved:'smtp.zoho.com' @ system.net.servicepoint.getconnection(pooledstream object owner, boolean async, ipaddress& address, socket& socket& abortsocket6) @ system.net.pooledstream.activate(object boolean async, generalasyncdelegate asynccallback) @ system.net.connectionpool.getconnection(object owningobject, asynccallback, int32 creationtimeout) @ system.net.mail.smtpconnection.getconnection(servicepoint servicepoint) @ system.net.mail.smtptransport.getconnection(servicepoint servicepoint) @ system.net.mail.smtpclient.getconnection() @ system.net.mail.smtpclient.send(mailmessage message)
here code:
system.io.memorystream ms = new system.io.memorystream(); ms = new memorystream(pdfsharpconvert(rawfilehtml)); system.net.mime.contenttype ct = new system.net.mime.contenttype(system.net.mime.mediatypenames.application.pdf); system.net.mail.attachment attach = new system.net.mail.attachment(ms, ct); attach.contentdisposition.filename = filename + ".pdf"; var message = new mailmessage(); message.to.add(new mailaddress(recepientemail)); message.attachments.add(attach); message.subject = subject; message.body = body; message.isbodyhtml = true; message.deliverynotificationoptions = deliverynotificationoptions.onfailure; using (var smtp = new smtpclient()) { smtp.send(message); } issuccess = true; ms.close();
here config mail
<smtp from="myfromemail"> <network host="smtp.zoho.com" port="587" username="myusername" password="mypassword" enablessl="true" /> </smtp>
please how solve problem
thank you.
Comments
Post a Comment