|
Hmm...
There have been umpteen articles on this topic in C#.
MailMessage msg = new MailMessage();
msg.From = "crawler@deepak.portland.co.uk";
msg.To = "crawler@deepak.portland.co.uk";
msg.Subject = "Test";
msg.Body = "Hi! Hello" +"\nSent Via MailMessage and SmtpMail Class";
SmtpMail.SmtpServer = "smtp.yourmailserver.yourisp.com";
SmtpMail.Send(msg);
SmtpMail.Send("crawler@deepak.portland.co.uk","crawler@deepak.portland.co.uk","Test","Hi! Hello\nSent Via SmtpMail class");
Include System.Web.Mail namespace for the above methods to be visible to the compiler.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
Deepak Kumar Vasudevan wrote:
There have been umpteen articles on this topic in C#.
But he was asking about SMTP with authentication....;P
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
Try adding the username and password to the front of the URl of the SMTP server. eg
user:pass@smtp.isp.net
Not sure if it will work though.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
Thanks.
My Mail Server POP3 account username is: info@xyz.com
and when I try what you suggested, I get no answer.
Would you suggest another solution?
Regards,
Sassan
|
|
|
|
|
You may use this class and add the following code to authenticate, just after sending the HELO command:
<br />
buf.Append("HELO ");<br />
buf.Append(host);<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
buf.Length = 0;<br />
<br />
if(!AuthLoginPlain(con, user, password)) {<br />
con.Close();<br />
throw ....
}<br />
<br />
...<br />
<br />
<br />
private bool AuthLoginPlain(SmtpConnection con, string user, string pass)<br />
{<br />
StringBuilder buf = new StringBuilder();<br />
byte [] b_user = System.Text.Encoding.ASCII.GetBytes(user);<br />
byte [] b_pass = System.Text.Encoding.ASCII.GetBytes(pass);<br />
string response;<br />
string res;<br />
string data;<br />
int code;<br />
buf.Append("AUTH LOGIN");<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
buf.Length = 0;<br />
if(code == 334) <br />
{<br />
response = response.Substring(4);<br />
res = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(response));<br />
if(res == "Username:") <br />
{<br />
data = Convert.ToBase64String(b_user);<br />
buf.Append(data);<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
buf.Length = 0;<br />
}<br />
if(code != 334) <br />
{<br />
return false;<br />
}<br />
response = response.Substring(4);<br />
res = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(response));<br />
if(res == "Password:") <br />
{<br />
data = Convert.ToBase64String(b_pass);<br />
buf.Append(data);<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
if(code != 235) <br />
{<br />
return false;<br />
}<br />
return true;<br />
}<br />
}<br />
return false;<br />
}<br />
Cheers,
John
|
|
|
|
|
Hello all,
Can someone suggest components for the following:
1. PDF generation
2. Spell checker
Smitha
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant, and she fell on me. Then it wouldn't seem quite so funny.
|
|
|
|
|
i have a spell checker program that uses the internet i didnt write it.. but i have used it and it works. i can email it too you if you like. im trying to find the site i downloaded it from. but i cant remeber where.
The Code Project Is Your Friend...
|
|
|
|
|
|
Guys,
How can create a C# file splitter program to slice large files to multiple pieces?
Jassim Rahma
|
|
|
|
|
|
can someone direct me to some good coding style guides..other then whats at msdn... thank you.
jesse M
The Code Project Is Your Friend...
|
|
|
|
|
|
|
I WANT make it clear that i dont want the highlighted code to run but it does, can make someone tell me why?
the permissions (intersecting all policy levels) for the assembly are unrestricted access to reflection. I checked it myself. I'm sure there is no mistake in the policy configurations
using System;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
[assembly:ReflectionPermissionAttribute(SecurityAction.RequestRefuse,Unrestricted=true, Flags = ReflectionPermissionFlag.AllFlags)]
namespace reflectsecuritytest
{
public class mo
{
public static void met( int i )
{
}
public static void met( float f )
{
}
public static void met( string s )
{
}
public static int met( decimal d )
{
return 1;
}
public static void met( object o )
{
}
public int i = 9;
public static int x = 2;
private int pr
{
get
{
return 2;
}
}
}
[
ReflectionPermissionAttribute(
SecurityAction.Deny,
Flags = ReflectionPermissionFlag.AllFlags,
Unrestricted = true
)
]
class Class1
{
public static void PermisosReflect()
{
ReflectionPermission sec =
new ReflectionPermission(
ReflectionPermissionFlag.AllFlags
);
try {
sec.Deny();
//*************************
//*************************
// *********************************
// the next code is supposed not to execute, but it does
//*************************
//*************************
//*************************
Type t = typeof( mo );
BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Instance | BindingFlags.Static;
foreach( MemberInfo mi in t.GetMembers( bf ) )
{
Console.WriteLine( mi );
};
} catch( SecurityException e ){
Console.WriteLine( e );
}
}
public static void Deny()
{
Console.WriteLine("before calling");
ReflectionPermission sec =
new ReflectionPermission(
ReflectionPermissionFlag.AllFlags
);
sec.Deny();
PermisosReflect();
Console.WriteLine("after calling");
}
[STAThread]
static void Main(string[] args)
{
Deny();
Console.ReadLine();
}
}
}
|
|
|
|
|
Sorry i am new heer and didnt know how to post a message...so im just trying it out so Greetings all
|
|
|
|
|
Ρhoenix wrote:
Sorry i am new heer and didnt know how to post a message...so im just trying it out so Greetings all
You picked a bad spot to test if the site works ( which it obviously does, or there messages would not be here ), but welcome nevertheless.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Hi Phoenix,
You are welcome to try sending greetings and other test messages. But perhaps you are just out of the track. CodeProject has forums like Lounge etc, where you can post messages, that do not fit into Programming environments.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
IS there any clean solution to do that ? If you only use Windows Forms, the solution is 50% Clean by switching Language Property of Form ( much work...)
but what's about the text you use in your code, in your classes etc ? which way does microsoft provide, prefer ?
Any hints ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
The probably easiest way to handle strings is to add Assembly Resource Files (for each supported language 1) to your application. Then use a System.Resources.ResourceManager to read strings from the Resource file. When getting a string, the CurrentCulture is checked and the correct string is retrieved. Let me know if this helps or you need further assistence.
Matthias
You'll never master any language, except maybe VB, because there's nothing to it. (Lounge/Christian Graus)
www.mattbart.org Sonork ID: 100.32002
|
|
|
|
|
Hi,
thanks for your hint, but i still know this solution, but it's too complicated, i think. There must be a tool or something else to edit string resources, like
name lang1 lang2 lang3 etc..
and after you edit your resources, you click "Build", and you're resx files are builded. At this moment i'm checking out the "normal" way, but i guess that's no way i will follow.
Are there tools to build the resource files easy and fast ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
resgen seems to be tool to solve this. With resgen it's possible to extract resources to a text file from a resx file or binary resource file.
I will create a tool which use this features to edit my resources.
.:Greets from Jerry Maguire:.
|
|
|
|
|
I have a ResMan tool available off my site (GNU Public LIcense)...
Allows you to create / edit resx files. Supports text and images. Source code included.
http://www.ian-space.com/[^] (you do, however, have to register before you can download anything.
|
|
|
|
|
Hi,
I want to use DataSet and OleDbDataAdapter for manipulating some tables of a database. I know that when I want to do it for a table I can use below code:
<br />
{<br />
DataSet custDS = new DataSet();<br />
OleDbConnection myConn = new OleDbConnection(myConnection);<br />
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();<br />
myDataAdapter.SelectCommand = new OleDbCommand();<br />
myDataAdapter.SelectCommand.Connection = myConnection;<br />
<br />
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);<br />
<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Customers";<br />
myDataAdapter.Fill(custDS, "Customers");<br />
<br />
<br />
myDataAdapter.Update(custDS, "Customers");<br />
<br />
}<br />
but when I want to use more tables I have, some problems:
<br />
{<br />
DataSet custDS = new DataSet();<br />
OleDbConnection myConn = new OleDbConnection(myConnection);<br />
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();<br />
myDataAdapter.SelectCommand = new OleDbCommand();<br />
myDataAdapter.SelectCommand.Connection = myConnection;<br />
<br />
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);<br />
<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Customers";<br />
myDataAdapter.Fill(custDS, "Customers");<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Orders";<br />
myDataAdapter.Fill(custDS, "Orders");<br />
myDataAdapter.SelectCommand.CommandText = "Select * from Products";<br />
myDataAdapter.Fill(custDS, "Products");<br />
<br />
<br />
myDataAdapter.Update(custDS, "Customers");<br />
myDataAdapter.Update(custDS, "Orders");<br />
myDataAdapter.Update(custDS, "Products");<br />
<br />
}<br />
Because the myDataAdapter only gives one SelectCommand and CommandBuilder generates some commannds for one of tables. So myDataAdapter.Update method works for one of tables.
Can anyone help me please? How can I use OleDbDataAdpter, DataSet and CommandBuilder to solve my problem?
|
|
|
|
|
mkomasi wrote:
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);
myDataAdapter.SelectCommand.CommandText = "Select * from Customers";
myDataAdapter.Fill(custDS, "Customers");
myDataAdapter.SelectCommand.CommandText = "Select * from Orders";
myDataAdapter.Fill(custDS, "Orders");
myDataAdapter.SelectCommand.CommandText = "Select * from Products";
myDataAdapter.Fill(custDS, "Products");
You need to run the COmmandBuilder each time after you change your "select" statement. But then u have a problem with the Update (you will have to do the whole thing again). I recommend setting up a dataadapter for each table.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
hi @ll!
Is there any way to get a list of all computers in the network? (per C#)
thanks for any Ideas (I've got none
|
|
|
|