Showing results for 
Show  only  | Search instead for 
Did you mean: 

Office 365 sending email from C#

I am trying to send email through my c# code but It is giving error 

An attempt was made to access a socket in a way forbidden by its access permissions

my code for sending email is 


SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("", "password");
client.Port = 587;
client.Host = "";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;



 I contacted godaddy support but they said everything is good at their side. 


Hello @hzuberi ,


Welcome to the Community!  I wanted to reach out to let you know I've seen your post, but sending emails with C# is not something I'm familiar with.  Just curious, what benefit or advantage do you have in sending this way versus through Webmail?  

Hopefully a coding guru in our community will see your post, but if you need server settings, this article  should ensure you have the correct ones.  Have a great weekend! 

Sales and Support available 24/7 via phone or chat