Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I am developing windows mobile application, and I am trying to send an mail, but it doesn't send mail

My code is,
C#
private void btnsubmit_Click(object sender, EventArgs e)
      {
          try
          {
              OutlookSession ol = new OutlookSession();
              EmailMessage em = new EmailMessage();
              em.To.Add(new Recipient("iyal", "iyalarasi.r@winxsolutions.com"));
              em.Subject = "Request For Leave";
              em.BodyText = txteno.Text + "request" + cb1.SelectedItem.ToString() + "leave for" + txtreason.Text;
              EmailAccount ea = ol.EmailAccounts[0];
              em.Send(ea);
             // MessagingApplication.Synchronize("iyalarasi.r@winxsolutions.com");
              MessageBox.Show("mail sent");
              Form2 f2 = new Form2();
              f2.Show();
              f2.lblmsg.Text = "You have Applied Leave";
          }
          catch (PocketOutlookException ex)
          {
              lblmsg1.Text = ex.ToString();
          }
          catch (Exception e1)
          {
              lblmsg1.Text = e1.ToString();
          }

I checked with breakpoint,It doesn't provide any error,but i can;t receive mail.

Please Help me,I am new to this application. and need finish this task today
Posted
Updated 18-Oct-12 19:07pm
v2

Please check your firewall setting.

Thanks,
Prashant
 
Share this answer
 
Comments
iyalarasi 19-Oct-12 1:35am    
can't understand.

How to check my firewall.

I didn't configure any firewall settings.
See this example..and try it yourself
http://msdn.microsoft.com/en-us/library/bb158768.aspx[^]
 
Share this answer
 
Comments
iyalarasi 19-Oct-12 3:14am    
I have seen this.But my doubt is that we need to run this application only in pocket pc or windows mobile device professional edition 6.5.3?
Because while i run this in pocket pc in my outbox mail is there.
ridoy 19-Oct-12 3:19am    
it also supports windows mobile
iyalarasi 19-Oct-12 4:10am    
I have changed coding as,
private void btnsubmit_Click(object sender, EventArgs e)
{
try
{
OutlookSession ol = new OutlookSession();
EmailMessage em = new EmailMessage();
Recipient r=new Recipient ("iyalarasi.r", "iyalarasi.r@winxsolutions.com");

em.To.Add(r);
em.Subject = "Request For Leave";
em.BodyText = txteno.Text + "request" + cb1.SelectedItem.ToString() + "leave for" + txtreason.Text;
EmailAccount ea = ol.EmailAccounts[0];
//ea.Send(em);
em.Send("iyalarasi.r");//Account name in outlook
MessagingApplication.Synchronize("iyalarasi.r");
MessageBox.Show("mail sent");
Form2 f2 = new Form2();
f2.Show();
f2.lblmsg.Text = "You have Applied Leave";
}
catch (PocketOutlookException ex)
{
lblmsg1.Text = ex.ToString();
}
catch (Exception e1)
{
lblmsg1.Text = e1.ToString();
}

}

In that it show error as invalid account name in catch. but the Account name I have entered is correct
ridoy 19-Oct-12 4:53am    
See some more links over it..if it works let me know..
http://msdn.microsoft.com/en-us/library/hh394003%28v=VS.92%29.aspx
http://ratneshkhandelwal.wordpress.com/blogs-codes/code-to-send-email-in-windows-phone-7-using-c/
http://www.c-sharpcorner.com/UploadFile/74f20d/sending-mail-via-windows-phone-7/
iyalarasi 22-Oct-12 0:51am    
It reqiures microsoft.phone.tasks dll reference. But i didn't have that.It tells to install windows sdk7.0 platform.
what I can do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900