|
Hi all,
Trying to send mail with System.Net.SmtpClient, using very simple code
just for testing:
SmtpClient smtp = new SmtpClient("mail.server.com", 25);
smtp.Credentials = new
System.Net.NetworkCredential("user", "password");
try
{
smtp.Send("sen...@server.com",
"recipi...@server.com",
"Subject",
"Body");
MessageBox.Show("Mail Sent!");
}
catch (Exception ex)
{
txtErrorMsg.Text = ex.ToString();
}
BTW, the mail.server.com is not mine, it's an ISP mail server.
On my local machine, this code works fine and actualy sending the
mail.
BUT, on my remote server the same code produces the exceptions as
follows:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: No connection could be made
because the target machine actively refused it
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream,
Object owner, Boolean async, IPAddress& address, Socket& abortSocket,
Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean
async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject,
GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject,
GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at System.Net.Mail.SmtpClient.Send(String from, String recipients,
String subject, String body)
at TestWindows.FrmSendSMTPMail.btnSend_Click(Object sender,
EventArgs e)
Weird stuff...
My remote server has Windows Server 2003.
So, am I missing something?
Sounds to me like a connectivity problem... How can I check that?
Thanks in advance,
Danny
|
|
|
|
|
I'd guess that your ISP rejects connections from IP addresses that do not belong to them.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You may be able to authenticate to your isp's smtp server by passing it your user credentials.
Alteratively, consider using the windows server SMTP service.
"You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"
|
|
|
|
|
Hi
I am trying to create a Richtextbox that able to be able to copy and paste from Word document. The method to paste from word document I have used is Paste(); However there is a problem when in Word document there is table. If the table is located further to the right then when pasted to the richtextbox then the richtextbox will cover a bit of the table.
I have a screen shot here
http://www.mediafire.com/imageview.php?quickkey=3xdzy9xnjmj&thumb=4
Can you please tell me is that the right method to use to paste the table from Word file into richtextbox? Is there any way that I can fix that please?
Thank you very much. I really do appreciate your help.
Best regards
-- modified at 11:59 Thursday 1st November, 2007
|
|
|
|
|
Hi!
The regular RichTextBox cannot display everything you can have in a Word document and some features can be transferred but will not be shown exactly the way they appear in Word.
Tables are among these features.
You can come a little closer to Word if you use a more recent version of the Rich Edit Control than the one the regular RTB uses (V2.0).
This can be done by overriding CreateParams in a class deriving from RichTextBox like this:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr LoadLibrary(string lpFileName);
protected override CreateParams CreateParams
{
get
{
CreateParams par = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
par.ClassName = "RICHEDIT50W";
}
return par;
}
But unfortunately you'll never achieve a 100% match...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
HI,
i know there is a "dateTimePicker" Cell Style
but i do not know how to build, HELP
is there an existing Example of it that i can take and Add-On to my APP?
THNKS IN ADVANCE
Have Fun
Never forget it
|
|
|
|
|
My DataGrid contain :
<ItemTemplate>
<a href='<%# "javascript:void(window.open('..SubPages/MusicDetail.aspx?item_id=DataBinder.Eval(Container.DataItem,("id_BaiHat"))&type=type','toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=250'))" %>'><%#DataBinder.Eval(Container.DataItem, "TenBaiHat") %></a>
</ItemTemplate>
This code is used to open a popup window when user click this link.
But I get error at: '<%# "javascript:void(window.open('..SubPages/MusicDetail.aspx?item_id=DataBinder.Eval(Container.DataItem,("id_BaiHat"))&type=type'
I don't know how to fix it.help me please !
Thanks advace.
nothing
|
|
|
|
|
You should place the literal javascript code outside of the databinding expression block. Only your call to DataBinder.Eval should be placed within this block.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Can you give me your code exactly ?
nothing
|
|
|
|
|
I've already told you what to do. Only your call to DataBinder.Eval needs to be placed inside the <%# %> block. Your literal Javascript code should be placed outside of this block, the same as your anchor tag.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I rewrite my code and it like below:
<a href="javascript:void(window.open('../SubPages/MusicDetail.aspx?item_id=<%#DataBinder.Eval(Container.DataItem,("id_BaiHat"))%>&type=type','toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=250'))"><%#DataBinder.Eval(Container.DataItem, "TenBaiHat") %></a>
There is no error any more.But it can open new window when I click this link.Nothing happened after clicking this link.
nothing
|
|
|
|
|
Have you viewed the source for your page output? Look at how the anchor tag has been constructed and see if there are any obvious problems with the HTML code.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I have two Xml document. Both the documents has same root node and also same 12 parent nodes.
Now i need to merge the second document with the first document with the following three conditions,
1) If the child node of a parent node in second doc is not available in child nodes of corresponding parent node in first doc, then append the child nodes with all its child node(Sub childs) to the parent node of first doc.
2)If the child node of a parent node in second doc is available in child nodes of corresponding parent node in first doc,
but the sub childs are different then append the sub childs to the corresponding child node of the first doc.
3)If the child node of a parent node in second doc is available in child nodes of corresponding parent node in first doc, and the sub childs are exactly same then nothing has to be done.
Can anyone help me out.
The xml file is not too large and the order is not under consideration.
Thanks,
Srikanth
|
|
|
|
|
Sri_3464 wrote: have two Xml document. Both the documents has same root node and also same 12 parent nodes.
Now i need to merge the second document with the first document with the following three conditions,
Sound like a homework. Have you tried something...what problems do you have?
Search Google [^]. You'll find anything there.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hello
i do something like this:
public static bool CreateNewWebsite(WebSiteInfo WebsiteInformation)
{
string strIISPath = WebSiteInfo.IIS + WebsiteInformation.ServerName + WebSiteInfo.WEBSERVICE;
// Check if path points to any existing directory
if (DirectoryEntry.Exists(strIISPath))
{
///and here comes exception
--
The system cannot find the path specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The system cannot find the path specified.
--
While debuging i found out that exception is here:
DirectoryEntry.Exists(strIISPath)
but strIISPath is right("IIS://server_name/W3SVC"),so,cant find the reason of the problem
thnx
|
|
|
|
|
DimaPursanov wrote: but strIISPath is right("IIS://server_name/W3SVC"),
it should be
"IIS://"+this._strServerName+"/W3SVC/1/Root"
This will work !!!!
if any prob then inform me.....
-------
|
|
|
|
|
public string CreateVDir()
{
System.DirectoryServices.DirectoryEntry oDE;
System.DirectoryServices.DirectoryEntries oDC;
System.DirectoryServices.DirectoryEntry oVirDir;
try
{
//check whether to create FTP or Web IIS Virtual Directory
if (this._strDirectoryType == VDirType.WEB_IIS_DIR)
{
oDE = new DirectoryEntry("IIS://"+this._strServerName+"/W3SVC/1/Root");
}
//Get Default Web Site
oDC = oDE.Children;
//Add row
oVirDir = oDC.Add(this._strVDirName, oDE.SchemaClassName.ToString());
//Commit changes for Schema class File
oVirDir.CommitChanges();
//Ask if Virtual Directory Exist
if(Directory.Exists(this._strPhysicalPath))
{
Console.WriteLine("Error");
}
//Create physical path if it does not exists
if (!Directory.Exists(this._strPhysicalPath))
{
Directory.CreateDirectory(this._strPhysicalPath);
}
//Set virtual directory to physical path
oVirDir.Properties["Path"].Value = this._strPhysicalPath;
//Set properties
oVirDir.Properties["AccessRead"][0] = true;
oVirDir.Properties["AccessWrite"][0] = true;
oVirDir.Properties["AccessExecute"][0] = true;
oVirDir.Properties["EnableDirBrowsing"][0] = true;
oVirDir.Properties["EnableDefaultDoc"][0] = true;
oVirDir.Properties["DefaultDoc"][0] = "default.aspx";
oVirDir.Properties["AuthAnonymous"][0] = false;
oVirDir.Properties["AuthBasic"][0] = false;
oVirDir.Properties["AuthNTLM"][0] = true;
//Create Application for IIS Application (as for ASP.NET)
if (this._strDirectoryType == VDirType.WEB_IIS_DIR)
{
oVirDir.Invoke("AppCreate", true);
oVirDir.Properties["AppFriendlyName"][0] = this._strVDirName;
}
//Save all the changes
oVirDir.CommitChanges();
return "Virtual Directory created sucessfully";
}
catch (Exception exc)
{
return exc.Message.ToString();
}
}
U can use this one also....
|
|
|
|
|
Abhijit Jana,thank you very much for your answer!
but now exception is here:
oDE = new DirectoryEntry("IIS://" + ConfigurationManager.AppSettings["ServerName"].ToString() + "/W3SVC/1/Root");
//Get Default Web Site
oDC = oDE.Children;
//Add row
oVirDir = oDC.Add(WebsiteInformation.SiteName, oDE.SchemaClassName.ToString());
..exception is the same..
|
|
|
|
|
how to pass a link through gridview using linkbutton or onclick event..pls help me out.
alok2171
|
|
|
|
|
How to Identify the Modified values in Dataset?
---
Regards
ilango gandhi
' Knowledge can only be got in one way, the way of experience; there is no other way to know.'
|
|
|
|
|
Check the RowState property of each rows...
if(row.RowState == DataRowState.Modified)
{
}else{
}
...or get a DataView for the modified rows:
DataView view = new DataView(dataTable, filter, fieldName, DataViewRowState.ModifiedCurrent);
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Is there any completed documentation to check if I wanna know all new features of C# 3.0? I read C# specification a lit bit but it seems it covered all features of C# (not just only C# 3.0 )....
Any idea would be appreciated. Thanks in advance.
|
|
|
|
|
|
Thanks. I will take a look... I wonder how come MS doesn't have the full documentation for new changes..
|
|
|
|
|
on loading xml string in xmldocument it gives error illegal characters in path even if i give sinfle mode in it like
Can any body tell me the reason
Its urgent !!!
Thanks in advance....
Gaurav
|
|
|
|