Skip to main content

Posts

Unable to send email using SMTP Server (Failure sending mail error)

You can configure the SMTP server or can use Gmail SMTP to send email. But sometime you face the error read as ‘Failure sending mail.’ , though you have added correct configuration and code to send email is correct. And then you wonder what went wrong due to which email not sent to recipient. Exception Detail and Reason: If you check the exception details then it read like: An attempt was made to access a socket in a way forbidden by its access permissions 173.194.79.108:587 This issue may be due to firewall or Antivirus blocking your port to send mail. Solution: Disable Firewall or Antivirus which is blocking port to send mail.  If you are using McAfee then unblock McAfee port blocking for outgoing SMTP mail as mentioned below: ·          Go to system tray and right click on McAfee icon and select VirusScan Console ·          Right click on Access Protection and select Propert...

How to Send email in ASP.Net and C# using Gmail SMTP Server

If you want to add functionality of sending email for your ASP.Net web application one way is to configure your own SMTP (for large application, companies configure their own mail server), however if you have not access to any SMTP server, don’t worry Google is there to rescue the things. You can send email through Gmail SMTP Mail Server; for this you just need to use an email address and password of a valid Gmail account and the Gmail SMTP Mail Server settings. In this article I will explain how to send email in ASP.Net using Gmail SMTP Server. Before proceeding further let’s understand the required MailMessage Class Properties: Property Description From Email address of Sender To Email Address of Recipient(s) CC Carbon Copies Email addresses (if any) BCC Blind Carbon Copies Email addresses (if any) Subject Subject of the Email IsBodyHtml ...

How to swap words in a string using LINQ in C#

Swapping of word inside a string using LINQ requires a small piece of code. Requirement: For example you are getting name of user as “FirstName LastName ”, but on UI you want to show name as “LastName FirstName”. In such scenario you can take help of LINQ and swap two words like mentioned below: var userName = "Sandeep Kumar" ; //Swap FirstName and LastName. userName = string .Join( " " , userName.Split( ' ' ).Reverse()).Trim(); Output: userName contains “Kumar Sandeep” after words are swapped.

How to get all Uppercase or Lowercase word using LINQ in C#

In this post, I'll show how you can filter out uppercase or lowercase words in a string Code to find uppercase or lowercase words in given string: var str = "Test String With lower And UPPER Case" ; //Find all Uppercase words var upperItems = str.Split( ' ' )                 .Where(s => String .Equals(s, s.ToUpper(),                                             StringComparison .Ordinal)); //Find all Lowercase words var lowerItems = str.Split( ' ' )                 .Where(s => String .Equals(s, s.ToLower(),             ...

How to get selected text or value from dropdown list using jquery

In this post, I'll show how you can get the selected text and selected value of dropdown using jQuery. Dropdown can be ASP.Net dropdown or HTML dropdown. Let’s define one dropdown and button: <!--Dropdown can be either of ASP.Net --> < asp : DropDownList ID ="ddlGender" runat ="server">    < asp : ListItem Value ="-1"> - Select- </ asp : ListItem >    < asp : ListItem Value ="1"> Male </ asp : ListItem >    < asp : ListItem Value ="2"> Female </ asp : ListItem > </ asp : DropDownList > <!--Or HTML select--> < select id ="ddlGender">     < option value ="-1"> -Select- </ option >     < option value ="1"> Male </ option >     < option value ="2"> Female </ option > </ select > < input type ="button" id ="getValue...