Click here to Skip to main content
15,881,852 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to check that dsn which is created used for Sql Server or Access using C# Pin
PIEBALDconsult22-Feb-12 2:56
mvePIEBALDconsult22-Feb-12 2:56 
GeneralRe: How to check that dsn which is created used for Sql Server or Access using C# Pin
Awadhendra123422-Feb-12 3:24
Awadhendra123422-Feb-12 3:24 
GeneralRe: How to check that dsn which is created used for Sql Server or Access using C# Pin
PIEBALDconsult22-Feb-12 4:00
mvePIEBALDconsult22-Feb-12 4:00 
QuestionDetect Marked Checkbox using OCR Pin
Zeyad Jalil22-Feb-12 2:12
professionalZeyad Jalil22-Feb-12 2:12 
AnswerRe: Detect Marked Checkbox using OCR PinPopular
enhzflep22-Feb-12 4:44
enhzflep22-Feb-12 4:44 
GeneralRe: Detect Marked Checkbox using OCR Pin
Zeyad Jalil22-Feb-12 20:29
professionalZeyad Jalil22-Feb-12 20:29 
GeneralRe: Detect Marked Checkbox using OCR Pin
enhzflep22-Feb-12 20:43
enhzflep22-Feb-12 20:43 
Questionsmtp unknown sender Pin
CS3421-Feb-12 23:23
CS3421-Feb-12 23:23 
Hello guys!

I am trying to use the following code to send an email to a mail server over a tcp connection. The code works great, however, when I try to send an email to someone, the receipt of my Email alwyes gets unknown sender(From). Am I missing something?

C#
TcpClient SmtpServ = new TcpClient("smtp.my.com", 25);
            string Data;
            byte[] szData;
            string CRLF = "\r\n";
 
            try
            {
                // initialization
                NetworkStream NetStrm = SmtpServ.GetStream();
                StreamReader RdStrm = new StreamReader(SmtpServ.GetStream());
                Console.WriteLine(RdStrm.ReadLine());
 
                // say hello to server and send response into log report
                Data = "HELO server" + CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Console.WriteLine(RdStrm.ReadLine());
                // send sender data
                Data = "MAIL From:" + " me@test.com" + CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Console.WriteLine(RdStrm.ReadLine());
 
                // send receiver data
                Data = "RCPT TO: " + "me@my.net" + CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Console.WriteLine(RdStrm.ReadLine());
 
                // send DATA
                Data = "DATA" + CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Console.WriteLine(RdStrm.ReadLine());
 
                // send content data
                Data = "SUBJECT: my subject\r\n\r\n";
                Data += "Hello there!\r\n";
                Data += ".\r\n";
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Console.WriteLine(RdStrm.ReadLine());
 

                // quit from server SMTP
                Data = "QUIT" + CRLF;
                szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
                NetStrm.Write(szData, 0, szData.Length);
                Console.WriteLine(RdStrm.ReadLine());
 
                // close connection
                NetStrm.Close();
                RdStrm.Close();
                Console.WriteLine("Close connection");
                Console.WriteLine("Send mail successly..");
 
            }
            catch (InvalidOperationException err)
            {
                Console.WriteLine("Error: " + err.ToString());
            }


Thanks,
AnswerRe: smtp unknown sender Pin
Richard MacCutchan22-Feb-12 3:14
mveRichard MacCutchan22-Feb-12 3:14 
Questionadd application to \\root\SecurityCenter2\antispywareproduct as antispyware Pin
abhinish21-Feb-12 23:12
abhinish21-Feb-12 23:12 
Questionhow can i scann image from scanner in C# Pin
A7mad_21-Feb-12 22:55
A7mad_21-Feb-12 22:55 
AnswerRe: how can i scann image from scanner in C# Pin
lukeer22-Feb-12 2:17
lukeer22-Feb-12 2:17 
Questiontrouble in connecting from C# to Postgre SQL. Pin
hellono121-Feb-12 20:46
hellono121-Feb-12 20:46 
AnswerRe: trouble in connecting from C# to Postgre SQL. Pin
BobJanova21-Feb-12 21:42
BobJanova21-Feb-12 21:42 
QuestionIntegration of .NET with retail billing machine Pin
tahernd21-Feb-12 19:14
tahernd21-Feb-12 19:14 
AnswerRe: Integration of .NET with retail billing machine Pin
Richard MacCutchan21-Feb-12 21:24
mveRichard MacCutchan21-Feb-12 21:24 
AnswerRe: Integration of .NET with retail billing machine Pin
Mycroft Holmes21-Feb-12 21:39
professionalMycroft Holmes21-Feb-12 21:39 
GeneralRe: Integration of .NET with retail billing machine Pin
tahernd22-Feb-12 0:26
tahernd22-Feb-12 0:26 
QuestionAny difference between Console App and Windows Service for HttpWebRequest..? [Solved] Pin
Paladin200021-Feb-12 6:38
Paladin200021-Feb-12 6:38 
AnswerRe: Any difference between Console App and Windows Service for HttpWebRequest..? Pin
jschell21-Feb-12 9:41
jschell21-Feb-12 9:41 
GeneralRe: Any difference between Console App and Windows Service for HttpWebRequest..? Pin
Paladin200021-Feb-12 10:10
Paladin200021-Feb-12 10:10 
AnswerRe: Any difference between Console App and Windows Service for HttpWebRequest..? Pin
Dave Kreskowiak21-Feb-12 15:08
mveDave Kreskowiak21-Feb-12 15:08 
GeneralRe: Any difference between Console App and Windows Service for HttpWebRequest..? Pin
Paladin200022-Feb-12 3:34
Paladin200022-Feb-12 3:34 
AnswerRe: Any difference between Console App and Windows Service for HttpWebRequest..? [Eureka!] Pin
Paladin200022-Feb-12 10:40
Paladin200022-Feb-12 10:40 
GeneralRe: Any difference between Console App and Windows Service for HttpWebRequest..? [Eureka!] Pin
jschell22-Feb-12 11:35
jschell22-Feb-12 11:35 

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.