我有代理在我的企业,我想测试代码X++连接互联网和发送电子邮件。
我不知道如何在dynamics中配置代理,也不知道可以在我的方法中添加哪些行代码X++:
void SendMail()
{
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.Attachment attachment;
System.Net.Mail.AttachmentCollection attachementCollection;
System.Net.Mail.SmtpClient smtpClient;
System.Net.Mail.MailAddress mailAddressFrom;
System.Net.Mail.MailAddress mailAddressTo;
str Body;
str Subject;
str SMTPServer;
str FileName;
str psw;
str login;
System.Net.Mail.SmtpDeliveryMethod stmpDeliveryMethod;
System.Net.WebProxy proxy;
ProxyIPAddress proxyIPAddress;
ProxyPortNum proxyPortNum;
System.Net.Sockets.Socket socket;
System.Net.NetworkCredential cred;
;
login ="mylogin@gmail.com";
psw="mypassword";
mailAddressFrom = new System.Net.Mail.MailAddress("mylogin@gmail.com","");
mailAddressTo = new System.Net.Mail.MailAddress("mylogin@gmail.com","");
Body = "<B>Body of the email</B>";
Subject = "Subject line for the email";
//SMTPServer = SysEmailParameters::find(false).SMTPRelayServerName;
mailMessage = new System.Net.Mail.MailMessage(mailAddressFrom, mailAddressTo);
mailmessage.set_Subject(Subject);
mailmessage.set_Body(Body);
cred = new System.Net.NetworkCredential(login, psw);
smtpClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
smtpClient.set_EnableSsl(true);
stmpDeliveryMethod = ClrInterop::parseClrEnum('System.Net.Mail.SmtpDeliveryMethod', 'SpecifiedPickupDirectory');
smtpClient.set_DeliveryMethod( stmpDeliveryMethod);
//smtpClient.DeliveryMethod()= System.net.mail.SmtpDeliveryMethod.Network);
smtpClient.set_UseDefaultCredentials(false);
smtpClient.set_Timeout(20000);
smtpClient.set_Credentials(cred); //.Credentials = cred;
proxy=new System.Net.WebProxy();
print 'On va envoyer! remarque : next msg est : "sa marche" ';
smtpClient.Send(mailMessage);
print 'sa marche';
//////////////////////////////////////////
CodeAccessPermission::revertAssert();
}例如,我在firefox或internet中配置代理参数以连接internet!我专营ip 192.168.66.33和端口1234!在动力学方面我不能这么做!
在c# w编辑web.config中:
我们将其添加到应用程序的web.config文件中。
在动力学中我们能改变什么?!!
Rq:
例如,我在firefox或internet中配置代理参数以连接internet!我专营ip 192.168.66.33和端口1234!在动力学方面我不能这么做!
在c# w编辑web.config中:
我们将其添加到应用程序的web.config文件中。
<system.net>
<defaultProxy>
<proxy proxyaddress="YourProxyIpAddress"/>
</defaultProxy>
</system.net>在动力学中我们能改变什么?!!
发布于 2012-09-27 15:29:40
您发布的链接(防火墙-config)允许外部访问aos服务器,与您的问题无关。
我还没有亲自测试它(我没有可以测试的代理),但是您是否尝试过在客户端bin目录中的ax32.exe.config中添加配置部分(或者如果您的代码在服务器上执行,则添加到服务器bin目录中)?
https://stackoverflow.com/questions/11010564
复制相似问题