1.
"non-invocable member 'System.Configuration.ConfigurationSettings.AppSettings' cannot used like a method"
Do like below (as suggested by
@CodeMaster_Noob).
MailAddress from = new MailAddress(ConfigurationSettings.AppSettings["fromemailid"].toString());
2.
"not all code paths return a value"
The method signature of
"send_mail" is...
public static bool send_mail(string toemailid)
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)
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:
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);
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);
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);
where both
from and
to are objects of
MailAddress Class.
Thanks...