Click here to Skip to main content
15,890,947 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: authorization in asp.net using sql databse Pin
Anand Desai26-Dec-08 20:25
Anand Desai26-Dec-08 20:25 
GeneralRe: authorization in asp.net using sql databse Pin
tejesh12326-Dec-08 20:34
tejesh12326-Dec-08 20:34 
GeneralRe: authorization in asp.net using sql databse Pin
Abhijit Jana26-Dec-08 21:21
professionalAbhijit Jana26-Dec-08 21:21 
GeneralRe: authorization in asp.net using sql databse Pin
tejesh12326-Dec-08 21:54
tejesh12326-Dec-08 21:54 
GeneralRe: authorization in asp.net using sql databse Pin
tejesh12328-Dec-08 22:12
tejesh12328-Dec-08 22:12 
Questioncheck Email exist or not Pin
kavitha_blueindia26-Dec-08 9:55
kavitha_blueindia26-Dec-08 9:55 
AnswerRe: check Email exist or not Pin
Christian Graus26-Dec-08 10:42
protectorChristian Graus26-Dec-08 10:42 
GeneralRe: check Email exist or not Pin
Tamer Oz26-Dec-08 20:00
Tamer Oz26-Dec-08 20:00 
There is no 100% guranteed way but you can check mx records. Try the following code it may give an idea.

public class MailValidator
{
private bool mResult = false;
public bool Result
{
get { return mResult; }
set { mResult = value; }
}
private string mError = "";
public string Error
{
get { return mError; }
set { mError = value; }
}
private string mMailAddress = "";
public string MailAddress
{
get { return mMailAddress; }
set { mMailAddress = value; }
}
public MailValidator(string mailAddress)
{
mMailAddress = mailAddress;
}
public bool MailExists()
{
string domainName = mMailAddress.Substring(mMailAddress.IndexOf("@") + 1);
foreach (string str in Mx.GetMXRecords(domainName))
{
TcpClient insTcpClient=null;
try
{
//MessageBox.Show(str);
insTcpClient = new TcpClient(str, 25);
NetworkStream ns = insTcpClient.GetStream();

byte[] recievedMessage = new byte[insTcpClient.ReceiveBufferSize];
ns.Read(recievedMessage, 0, insTcpClient.ReceiveBufferSize);
//MessageBox.Show(Encoding.ASCII.GetString(recievedMessage));

string messageToSend = "HELO\r\n";
byte[] buffer = System.Text.Encoding.GetEncoding(1254).GetBytes(messageToSend);
ns.Write(buffer, 0, buffer.Length);

recievedMessage = new byte[insTcpClient.ReceiveBufferSize];
ns.Read(recievedMessage, 0, insTcpClient.ReceiveBufferSize);
//MessageBox.Show(Encoding.ASCII.GetString(recievedMessage));

messageToSend = "MAIL FROM:<deneme@" + domainName + ">\r\n";
buffer = System.Text.Encoding.GetEncoding(1254).GetBytes(messageToSend);
ns.Write(buffer, 0, buffer.Length);

recievedMessage = new byte[insTcpClient.ReceiveBufferSize];
ns.Read(recievedMessage, 0, insTcpClient.ReceiveBufferSize);
//MessageBox.Show(Encoding.ASCII.GetString(recievedMessage));

messageToSend = "RCPT TO:<" + mMailAddress + ">\r\n";
buffer = System.Text.Encoding.GetEncoding(1254).GetBytes(messageToSend);
ns.Write(buffer, 0, buffer.Length);

recievedMessage = new byte[insTcpClient.ReceiveBufferSize];
ns.Read(recievedMessage, 0, insTcpClient.ReceiveBufferSize);
//MessageBox.Show(Encoding.ASCII.GetString(recievedMessage));
if (Encoding.ASCII.GetString(recievedMessage).StartsWith("250"))
{
mResult = true;

}
insTcpClient.GetStream().Close();
insTcpClient.Close();
}
catch (Exception ex)
{
mError += str + ": " + ex.Message; ;
}
}
return mResult;
}
}
public class Mx
{
public Mx()
{
}
[DllImport("dnsapi", EntryPoint = "DnsQuery_W", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszName, QueryTypes wType, QueryOptions options, int aipServers, ref IntPtr ppQueryResults, int pReserved);

[DllImport("dnsapi", CharSet = CharSet.Auto, SetLastError = true)]
private static extern void DnsRecordListFree(IntPtr pRecordList, int FreeType);

public static string[] GetMXRecords(string domain)
{

IntPtr ptr1 = IntPtr.Zero;
IntPtr ptr2 = IntPtr.Zero;
MXRecord recMx;
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
throw new NotSupportedException();
}
ArrayList list1 = new ArrayList();
int num1 = Mx.DnsQuery(ref domain, QueryTypes.DNS_TYPE_MX, QueryOptions.DNS_QUERY_BYPASS_CACHE, 0, ref ptr1, 0);
if (num1 != 0)
{
throw new Win32Exception(num1);
}
for (ptr2 = ptr1; !ptr2.Equals(IntPtr.Zero); ptr2 = recMx.pNext)
{
recMx = (MXRecord)Marshal.PtrToStructure(ptr2, typeof(MXRecord));
if (recMx.wType == 15)
{
string text1 = Marshal.PtrToStringAuto(recMx.pNameExchange);
list1.Add(text1);
}
}
Mx.DnsRecordListFree(ptr2, 0);
return (string[])list1.ToArray(typeof(string));
}

private enum QueryOptions
{
DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE = 1,
DNS_QUERY_BYPASS_CACHE = 8,
DNS_QUERY_DONT_RESET_TTL_VALUES = 0x100000,
DNS_QUERY_NO_HOSTS_FILE = 0x40,
DNS_QUERY_NO_LOCAL_NAME = 0x20,
DNS_QUERY_NO_NETBT = 0x80,
DNS_QUERY_NO_RECURSION = 4,
DNS_QUERY_NO_WIRE_QUERY = 0x10,
DNS_QUERY_RESERVED = -16777216,
DNS_QUERY_RETURN_MESSAGE = 0x200,
DNS_QUERY_STANDARD = 0,
DNS_QUERY_TREAT_AS_FQDN = 0x1000,
DNS_QUERY_USE_TCP_ONLY = 2,
DNS_QUERY_WIRE_ONLY = 0x100
}

private enum QueryTypes
{
DNS_TYPE_MX = 15
}

[StructLayout(LayoutKind.Sequential)]
private struct MXRecord
{
public IntPtr pNext;
public string pName;
public short wType;
public short wDataLength;
public int flags;
public int dwTtl;
public int dwReserved;
public IntPtr pNameExchange;
public short wPreference;
public short Pad;
}
}
AnswerWebservice to validate Email address Pin
David Mujica29-Dec-08 9:44
David Mujica29-Dec-08 9:44 
QuestionGridview control Problem Pin
amistry_petlad26-Dec-08 4:21
amistry_petlad26-Dec-08 4:21 
AnswerRe: Gridview control Problem Pin
Nishant Singh26-Dec-08 20:44
Nishant Singh26-Dec-08 20:44 
QuestionProblem in running web page Pin
Girish48126-Dec-08 0:00
Girish48126-Dec-08 0:00 
AnswerRe: Problem in running web page Pin
Brij26-Dec-08 0:05
mentorBrij26-Dec-08 0:05 
GeneralRe: Problem in running web page Pin
Girish48126-Dec-08 0:08
Girish48126-Dec-08 0:08 
GeneralRe: Problem in running web page Pin
Brij26-Dec-08 0:14
mentorBrij26-Dec-08 0:14 
GeneralRe: Problem in running web page Pin
Girish48126-Dec-08 0:25
Girish48126-Dec-08 0:25 
GeneralRe: Problem in running web page Pin
Brij26-Dec-08 0:39
mentorBrij26-Dec-08 0:39 
AnswerRe: Problem in running web page Pin
Abhijit Jana26-Dec-08 0:07
professionalAbhijit Jana26-Dec-08 0:07 
GeneralRe: Problem in running web page Pin
Girish48126-Dec-08 0:12
Girish48126-Dec-08 0:12 
GeneralRe: Problem in running web page Pin
Abhijit Jana26-Dec-08 0:27
professionalAbhijit Jana26-Dec-08 0:27 
GeneralRe: Problem in running web page Pin
Girish48126-Dec-08 0:31
Girish48126-Dec-08 0:31 
GeneralRe: Problem in running web page Pin
Abhijit Jana26-Dec-08 0:39
professionalAbhijit Jana26-Dec-08 0:39 
GeneralRe: Problem in running web page Pin
Girish48126-Dec-08 0:53
Girish48126-Dec-08 0:53 
GeneralRe: Problem in running web page Pin
Abhijit Jana26-Dec-08 1:01
professionalAbhijit Jana26-Dec-08 1:01 
GeneralRe: Problem in running web page Pin
Girish48126-Dec-08 1:25
Girish48126-Dec-08 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.