小编use*_*907的帖子

在使用SmtpClient发送电子邮件时,"邮箱不可用.服务器响应是:拒绝访问 - 无效的HELO名称"进行故障排除

我一直试图通过C#发送电子邮件.我用谷歌搜索了各种各样的例子,并从每个人和最有可能使用的标准代码中获取了一些零碎的东西.

string to = "receiver@domain.com";
string from = "sender@domain.com";
string subject = "Hello World!";
string body =  "Hello Body!";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.domain.com");
client.Credentials = new NetworkCredential("test@domain.com", "password");
client.Send(message);
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到错误说明

System.Net.Mail.SmtpException:邮箱不可用.服务器响应是:拒绝访问 - 无效的HELO名称(请参阅RFC2821 4.1.1.1)

那么,我现在该怎么办?SmtpClient应该是特殊的,只适用于特定的SMTP服务器吗?

c# smtpclient

10
推荐指数
1
解决办法
3万
查看次数

终止现有的 tcp 连接

有没有办法终止现有的连接?

例如,192.168.1.120 通过端口 8080 连接。

我想知道如何终止该连接?

非常感谢!

c++

5
推荐指数
1
解决办法
4873
查看次数

Windows UI自动化

我正在测试以下示例代码,并且每当我尝试运行它时,我将在下面显示错误.但是,calc.exe进程是成功执行的,那么句柄如何可能为null或为零?我希望你能理解我想要解决的问题.谢谢!代码示例来自http://www.mathpirate.net/log/tag/system-windows-automation/

UIAutomationClient.dll中发生未处理的"System.ArgumentException"类型异常附加信息:hwnd不能是IntPtr.Zero或null.

//Launches the Windows Calculator and gets the Main Window's Handle.
Process calculatorProcess = Process.Start("calc.exe");
calculatorProcess.WaitForInputIdle();
IntPtr calculatorWindowHandle = calculatorProcess.MainWindowHandle;

//Here I use a window handle to get an AutomationElement for a specific window.
AutomationElement calculatorElement = AutomationElement.FromHandle(calculatorWindowHandle);

if(calculatorElement == null)
{
    throw new Exception("Uh-oh, couldn't find the calculator...");
}

//Walks some of the more interesting properties on the AutomationElement.
Console.WriteLine("--------Element");
Console.WriteLine("AutomationId: {0}", calculatorElement.Current.AutomationId);
Console.WriteLine("Name: {0}", calculatorElement.Current.Name);
Console.WriteLine("ClassName: {0}", calculatorElement.Current.ClassName);
Console.WriteLine("ControlType: {0}", calculatorElement.Current.ControlType.ProgrammaticName);
Console.WriteLine("IsEnabled: {0}", calculatorElement.Current.IsEnabled);
Console.WriteLine("IsOffscreen: {0}", …
Run Code Online (Sandbox Code Playgroud)

c# user-interface automation

5
推荐指数
1
解决办法
6413
查看次数

将值打包成单个int

假设我有几个变量,如苹果,橙子,香蕉

我有8个苹果,1个橙子,4个香蕉.

是否有可能以某种方式将这些值转换为单个整数,并根据计算的整数值还原为原始值?

我在网上找到了一个例子.

int   age, gender, height;
short packed_info;
. . .
// packing
packed_info = (((age << 1) | gender) << 7) | height;
. . .
// unpacking
height = packed_info & 0x7f;
gender = (packed_info >>> 7) & 1;
age    = (packed_info >>> 8);
Run Code Online (Sandbox Code Playgroud)

但是,当我输入随机数时,它似乎不起作用.

java

4
推荐指数
1
解决办法
5550
查看次数

客户端和服务器

我想在两个应用程序之间创建一个连接.我应该使用Client-Server还是有另一种方式在彼此之间进行有效通信?是否有任何易于使用/重用和实现的预制C++网络客户端服务器库?

应用程序#1 <--->(客户端)<--->(服务器)<--->应用程序#2

谢谢!

c++

3
推荐指数
1
解决办法
488
查看次数

无法让代理使用Socket

我试图让代理使用Socket.但每次我尝试,它都会返回" 线程中的异常"pool-1-thread-1"java.lang.IllegalArgumentException:Invalid Proxy "异常错误

在java.net.Socket.(Socket.java:131)

但如果它的Proxy.Type.SOCKS,它的工作原理.

public void Test()
{
   Socket s = null;
   SocketAddress addr = null;
   Proxy proxy = null;

   addr = new InetSocketAddress("127.0.0.1", 8080);
   proxy = new Proxy(Proxy.Type.HTTP, addr);
   socket = new Socket(proxy); // This is the line that is triggering the exception
}
Run Code Online (Sandbox Code Playgroud)

java sockets proxy

2
推荐指数
1
解决办法
2534
查看次数

标签 统计

c# ×2

c++ ×2

java ×2

automation ×1

proxy ×1

smtpclient ×1

sockets ×1

user-interface ×1