<appSettings> <add key="fromemailid" value="development@relone"/> </appSettings>
代码隐藏我使用以下代码来获取frommailid
on codebehind i am using the following code to get frommailid
MailAddress from = new MailAddress(ConfigurationSettings.AppSettings("fromemailid"));但是我得到了 非可调用成员''System.Configuration.ConfigurationSettings.AppSettings''不能像方法一样使用。 应该怎样我要克服这个错误....请帮助我。 在default.aspx.cs页面上
but iam getting "non-invocable member ''System.Configuration.ConfigurationSettings.AppSettings'' cannot used like a method". What should I do to overcome this error....Please help me. on default.aspx.cs page
if (conn.send_mail(tomailid))
Error 1 Member ''WorkflowSystem.DataAccess.connection1.send_mail(string)'' cannot be accessed with an instance reference; qualify it with a type name instead C:\Users\user\Desktop\WebApplication1\WebApplication1\Default.aspx.cs 73 25 WebApplication1
on connection.cs页面
on connection.cs page
public static bool send_mail(string toemailid) { MailAddress from = new MailAddress(ConfigurationSettings.AppSettings["fromemailid"].ToString()); }
Error 2 ''WorkflowSystem.DataAccess.connection1.send_mail(string)'': not all code paths return a value C:\Users\user\Desktop\WebApplication1\WebApplication1\connection.cs 110 28 WebApplication1
现在要做什么...请帮助我。
What is to be done now...Please help me.
推荐答案你使用了错误的括号。 重写你的代码为 You are using wrong brackets. Rewrite your code as MailAddress from = new MailAddress(ConfigurationSettings.AppSettings["fromemailid"].toString());
1。 非可调用成员''System.Configuration.ConfigurationSettings.AppSettings''不能像方法一样使用 "non-invocable member ''System.Configuration.ConfigurationSettings.AppSettings'' cannot used like a method"
如下所示(由 @CodeMaster_Noob 建议)。
Do like below (as suggested by @CodeMaster_Noob).
MailAddress from = new MailAddress(ConfigurationSettings.AppSettings["fromemailid"].toString());2.
2.
并非所有代码路径都返回值 "not all code paths return a value"send_mail的方法签名是...
The method signature of "send_mail" is...
public static bool send_mail(string toemailid)返回类型是bool无效。 但你还没有什么都归还了您应该根据您的逻辑返回 true 或 false 。 更新 版本-1 好的,做两件事。 1.更改功能签名。
where return type is "bool" not void. But you have not returned anything. You should return either true or false according to your logic. Update Version-1 Ok, so do two things. 1. Change function signature.
public static bool send_mail(string toemailid)删除静态从这里开始。 所以,它将是...
Remove "static" from here. So, it will be...
public bool send_mail(string toemailid)静态方法只能在自己的类中调用,而不能从其他类调用。 2.设置断点在这个函数中,看看当你发送邮件时是否执行此功能。 版本 - 2 1.
The static methods can only be called within its own class, not from other classes. 2. Put a break point in this function and see whether execution comes to this function, when you are sending mail. Version-2 1.
Quote:错误2最佳重载方法匹配' 'System.Net.Mail.MailMessage.MailMessage(System.Net.Mail.MailAddress,System.Net.Mail.MailAddress)''有一些invali d参数C:\Users\user\Desktop\WebApplication1\WebApplication1\connection.cs 114 30 WebApplication1 错误3参数2:无法从''string''转换为' 'System.Net.Mail.MailAddress''C:\ Users \ user \Desktop\WebApplication1 \WebApplication1 \connection.cs 114 52 WebApplication1
Error 2 The best overloaded method match for ''System.Net.Mail.MailMessage.MailMessage(System.Net.Mail.MailAddress, System.Net.Mail.MailAddress)'' has some invalid arguments C:\Users\user\Desktop\WebApplication1\WebApplication1\connection.cs 114 30 WebApplication1 Error 3 Argument 2: cannot convert from ''string'' to ''System.Net.Mail.MailAddress'' C:\Users\user\Desktop\WebApplication1\WebApplication1\connection.cs 114 52 WebApplication1
写完之后下面
After writing like below
MailMessage mm = new MailMessage(from, to);上述错误将被修复。 as MailMessage类有如下构造函数......(你可以看到那里) 1. MailMessage构造函数(MailAddress,MailAddress) 你应该传递两个MailAddress对象。 2. MailMessage构造函数(字符串,字符串) 你应该传递两个字符串。 3. MailMessage构造函数(String,String,String,String) 你应该传递四个字符串。 - > 以前,你已写过......
the above errors will be fixed. As MailMessage Class has constructors like below...(you can see there) 1. MailMessage Constructor (MailAddress, MailAddress) where you should pass two MailAddress objects. 2. MailMessage Constructor (String, String) where you should pass two strings. 3. MailMessage Constructor (String, String, String, String) where you should pass four string. -> Previously, you have written...
MailMessage mm = new MailMessage(from, toemailid);其中来自是 MailAddress 类,但 toemailid 是一个字符串。 - > 现在你已经完成了正确的...
where from is a object of MailAddress Class, but toemailid was a string. -> Now you have done correct like...
MailMessage mm = new MailMessage(from, to);其中来自和到是 MailAddress 类的对象。 谢谢......
where both from and to are objects of MailAddress Class. Thanks...
更多推荐
从web.config中的appsettings获取邮件ID
发布评论