curiouswebster
asked on
Unable to connect to remote server
I have a C# program that runs on my laptop and send an email, using my remote website to relay the email. But when I run the same program from a Virtual Private Server of mine, I get the error: Unable to Connect to Remote Server.
Dos anyone have any idea about what could be the problem? I could include the source code, but suspect the problem lies in the configuration or environment, versus the code.
Any idea of what to check?
Thanks,
newbieweb
Dos anyone have any idea about what could be the problem? I could include the source code, but suspect the problem lies in the configuration or environment, versus the code.
Any idea of what to check?
Thanks,
newbieweb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
private static void SendCompletedCallback(obje
{
// Get the unique identifier for this asynchronous operation.
MailMessage eMailMessage = (MailMessage)e.UserState;
if (e.Cancelled)
{
//Console.WriteLine("[{0}]
}
if (e.Error != null)
{
//Console.WriteLine("[{0}]
}
else
{
string emailAddress = (string)eMailMessage.To[0]
eMailMessage.Dispose();
}
}
public void Send()
{
// Command line argument must the the SMTP host.
SmtpClient client = new SmtpClient(Handles.SMTPSer
NetworkCredential nc = new NetworkCredential(Handles.
client.UseDefaultCredentia
client.Credentials = nc;
// Specify the e-mail sender.
// Create a mailing address that includes a UTF8 character
// in the display name.
MailAddress from = new MailAddress(handles.FromEm
// Set destinations for the e-mail message.
MailAddress to = new MailAddress(contact.EmailA
// Specify the message content.
MailMessage message = new MailMessage(from, to);
message.Body = "";//"ApplicationPath=" + HttpContext.Current.Reques
// Include some non-ASCII characters in body and subject.
message.Body += Environment.NewLine;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = "test message from " + handles.Preferences.Machin
message.SubjectEncoding = System.Text.Encoding.UTF8;
// Set the method that is called back when the send operation ends.
client.SendCompleted += new SendCompletedEventHandler(
// The userState can be any object that allows your callback
// method to identify this send operation.
// For this example, the userToken is a string constant.
//Object userState = this;
Object userState = message;
client.SendAsync(message, userState);
}