|
Return the exception in the form of String format...!
[WebMethod]
Public string SendMail()
{
try
{
return "mail sent";
}
Catch(Exception ie)
{
return ie.Message;
}
}
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Hi,
Your method is very simple but when I tried to send the mail using webservice
I tried like:
testingservice service=new testingservice;
string message=service.send mail(,,,.....parameters);
where as I have declared the web service as
[WebMethod]
Public string SendMail(,,,.....parameters)
{
try
{
return "mail sent";
}
Catch(Exception ie)
{
return ie.Message;
}
}
I get an error and the application fails to rebuild
Cannot implicitly convert type 'System.IAsyncResult' to 'string'
Please reply
Thanks
Shankbond
|
|
|
|
|
Hi,
You misunderstood i think..!
You have to write a web method for sending mail
[WebMethod]
Public string SendMail(,,,.....parameters)
{
try
{
return "mail sent";
}
Catch(Exception ie)
{
return ie.Message;
}
}
if you wrote the logic for sending the mail show me the code..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Hi,
here is the code:
protected void Button4_Click(object sender, EventArgs e)
{
testingservice service = new testingservice();
AsyncCallback callback = new AsyncCallback(hello);
service.BeginSendMailGmail1(TextBoxto.Text.ToString(), TextBoxcc.Text.ToString(), TextBoxbcc.Text.ToString(), TextBoxbody.Text.ToString(), TextBoxsubject.Text.ToString(), TextBoxusername.Text.ToString(), TextBoxpassword.Text.ToString(), TextBoxserver.Text.ToString(), TextBoxport.Text.ToString(), TextBoxdisplayname.Text.ToString(),callback,sender);
Response.Redirect("default4.aspx");
}
here is the other method but it will always be completed =true
void hello(IAsyncResult result)
{
if (!result.IsCompleted)
{
Response.Write("failed");
}
}
the code for webservice:
[WebMethod]
public string SendMailGmail1(string To, string Cc, string Bcc, string body,string subject, string user_name, string password, string server_name, string portnumber, string display_name)
{
SmtpClient client = new SmtpClient();
MailMessage message = new MailMessage();
client.Port = Convert.ToInt32(portnumber);
client.Host = server_name;
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential(user_name, password);
client.EnableSsl = true;
try
{
message = new MailMessage(new MailAddress(user_name, display_name), new MailAddress(To));
if (Cc != "")
{
string[] array1 = Cc.Split(',');
for (int i = 0; i < array1.Length; i++)
{
message.CC.Add(array1[i].ToString());
}
}
if (Bcc != "")
{
string[] array2 = Bcc.Split(',');
for (int i = 0; i < array2.Length; i++)
{
message.Bcc.Add(array2[i].ToString());
}
}
message.Body = body;
message.Subject = subject;
message.IsBodyHtml = true;
client.Send(message);
message.Dispose();
return "sent successfully";
}
catch (Exception ex)
{
return ex.Message.ToString() + "----" + ex.InnerException.ToString();
}
}
Thanks
Shankbond
|
|
|
|
|
shankbond wrote: AsyncCallback callback = new AsyncCallback(hello);
I dont Understand why you need asychronous?
here is sample code i developed now
Modify your code depending on your requirement...!
[WebMethod]
public string SendMail()
{
try
{
MailMessage msg=new MailMessage ("From@xxx.com","To@xxx.com","Sub","body");
SmtpClient client = new SmtpClient("YourDomain", 25);
client .Send (msg);
return "hai";
}
catch (Exception ie)
{
return ie.Message ;
}
}
For Calling Webservice..!
localhost.WebService rss = new localhost.WebService();
string msg=rss.SendMail();
Response.Write(msg);
I am Going Bye May the group will help if you need further assistance..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
If The Web Service is in you application Keep the break point and check wats happening in webservice..!You can track the problem..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Cool it worked thanks.
I need the asynchronous mode only one problem left now how to pop up a message box or so, when the user is simply surfing on some other page?
Thanks
Shankbond
|
|
|
|
|
is there a way that I can add to Your reputation
Thanks
Shankbond
|
|
|
|
|
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
shankbond wrote: is there a way that I can add to Your reputation
I dont Know Much Abt reputation may be its new in codeproject I will Let you know After I know abt fully..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
HI Experts,
I have done designing on my computer...it looks good when i run it on browser..but when the same project is run on other machine which has little wider screen(19" monitor) the font,size of the controls does not remain same...i have used all HTML tables and placed controls in table...
I haven't used tags....will it b the reason ?
Sharing Of Knowledge Provides Solution....
|
|
|
|
|
If you are using css then apply following property in body tag of css
padding: 0 px;
margin:0auto;
Hope this will help you.....
Life Is Beautiful
|
|
|
|
|
Different monitors will always display web pages and applications differently.
To get round this always use a style sheet or inline styles if needed. Set widths, heights and font sizes to percentages. Within reason your page should display the same what ever the monitor.
|
|
|
|
|
Below line of code is working with IE but not with FireFox.
if(navigator.appName == "Microsoft Internet Explorer")
{
document.getElementById('txtEstimatedCommission').innerText = Commission.toFixed(2);
}
else
{
document.getElementById('txtEstimatedCommission').textContent = Commission.toFixed(2);
}
Please let me know where I am wrong.
Thanks
|
|
|
|
|
tRY value it will work in both..!
document.getElementById('<%= txtEstimatedCommission.ClientID %>').value=Commission.toFixed(2);
or
document.getElementById('<%= txtEstimatedCommission.ClientID %>').innerhtml=Commission.toFixed(2);
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
|
Any Time..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Hi all,
How i write a java script function which validates if Outer Gridview Checkbox is checked then inner grdiview Checkboxes not checked
if any of the inner Gridview Checkbox checked then Outer Gridview Checkbox will not Checked .
Best Regards,
Rameez
|
|
|
|
|
|
Thanks for reply,
I Checked the link but it is related with selection of all checkboxes
but i have to make validation if outer Gridview Checkbox checked then all inner Gridview Check box will be checked == false.
Do me this favor how i approach this.
Best Regards,
|
|
|
|
|
U can use javascript get the inner checkbox array first,and then iterate the array do what u want, i mean checked or not checked ur inner checkbox.
|
|
|
|
|
Thanks for the reply,
How i get Id of inner gridview and checkbox?
in java script
Best Regards
|
|
|
|
|
how can create a page in website Dynamically through one click
|
|
|
|
|
Waht Do You Mean by that?
Can You Specify Your Requirements more clearly ...!
So Group Can help..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
I developed a ASP.NET website....
every time i have to edit the code of website for creating new page.......
i want to know that is there any way to generate webpage dynamically means i dont hav to add page again n again, i want if i click a button or anything, a new webpage create automatically.......
i hope u got wat i want.....
Thanks in Advance
Regards
Richa
|
|
|
|