c #Exchange Web Service电子邮件,不能使用textbox.text信息作为用户 [英] c# Exchange Web Service email, can't use textbox.text info as user

查看:68
本文介绍了c #Exchange Web Service电子邮件,不能使用textbox.text信息作为用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些c#代码创建标准电子邮件并通过交换服务器发送。



此邮件中有6个文本框:from,to,subject ,交换服务器,用户和密码。



如果用户信息预设了用户信息(从mssql服务器找到),它将不会发送邮件。





这不起作用:

oServer.User = usertextbox.Text;



这样有效:

oServer.User =user1;

I have some c# code that creats a standard email and sends it through an exchange server.

I have 6 textboxes in this mailform: from,to,subject,exchangeserver,user and password.

If the user textbox is preset with the user info (found from mssql server) it won't send the mail.


This won't work:
oServer.User = usertextbox.Text;

This works:
oServer.User = "user1";

推荐答案

不够信息。



由于TextBox.Text只返回一个字符串,你只需要在你的usertextbox中键入user1(不带引号)就可以得到完全相同的东西。



服务器告诉你,根据你发送的数据,无论你做什么都没有被授权。
No enough information.

Since TextBox.Text just returns a string, you just have to type "user1" (without the quotes) into your usertextbox and you get the exact same thing.

The server is telling you that whatever you're doing isn't authorized, given the data that you sent.


我解决了。

问题是当在mssql数据库中找到用户id并写入bruger.Text时,它添加了一些空格。我认为这是.ToString();这样做。



我的解决方案就是写下这一行:

bruger.Text = bruger .Text.Replace(,);





I solved it.
The problem was that when the user id was found in the mssql database and writen to the bruger.Text it added some empty spaces. I think it's the .ToString();that did this.

My solution was to write this line:
bruger.Text = bruger.Text.Replace(" ", "");


//Brugers emailid
command.CommandText = "SELECT emailid from bruger WHERE bruger =            @bruger";

globalvariables.Con.Open();
command.ExecuteScalar();
bruger.Text = command.ExecuteScalar().ToString();

//Dette fjerner tomme mellemrum i bruger.Text som ToString har lavet
bruger.Text = bruger.Text.Replace(" ", "");

//Luk forbindelsen
globalvariables.Con.Close();


这篇关于c #Exchange Web Service电子邮件,不能使用textbox.text信息作为用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆