0

I want to send mail from my windows mobile application. I have configured new mail account on windows mobile emulator 6.5.3. with custom domain email provider, Now I am able to send and receive mails with that device,And I want to send mail from my code,when the button is clicked

Iyalarasi.R
  • 41
  • 1
  • 3
  • 7

1 Answers1

0

A code to send mail by code is available here: Sending mail in Windows mobile application in Windows

If you need more assistance, please provide more details.

EDIT: to make it more clear:

First you have to create an outlook session and specify the account to use:

public sendMail(string sMailAccount)
{
    session = new OutlookSession();
    //eMail = new EmailMessage();
    bool bFound = false;
    foreach (Account acc in session.EmailAccounts)
    {
        System.Diagnostics.Debug.WriteLine(acc.Name);
        if (acc.Name == sMailAccount)
            bFound = true;
    }
    if (bFound)
        account = session.EmailAccounts[sMailAccount];
    if (account != null)
    ...

The above starts a seesion and uses the provided string sMailsAccount to find an existing defined mail account. The string has to match any of the mail accounts you already have ce´reated in pocket outlook.

Then, when you want to send an eMail, you use the existing session:

public bool send(string sImagePath)
{
    if (account == null)
        return false;
    try
    {
        eMail = new EmailMessage();
        rcp = new Recipient(_to);
        eMail.To.Add(rcp);
        eMail.Subject = "Visitenkarten";
        eMail.BodyText = "VCard " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\r\nsent from eMDI2Mail";

        attachement = new Attachment(sImagePath);
        eMail.Attachments.Add(attachement);                
        eMail.Send(account);                
        //account.Send(eMail);
        if (this._syncImmediately)
        {
            if (this.account != null)
                Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.Synchronize(this.account);
        }
        return true;
    }
    ...

The above code creates a new eMail, attaches a file and sends the eMail immediately or lets outlook decide, wehn to send (at a specified interval). The eMail is send immediately, if Synchronize function is used.

Makes it more clear?

Community
  • 1
  • 1
josef
  • 5,951
  • 1
  • 13
  • 24
  • hi,I have doubt, that while I am sending mail through outlook,it shows error in synchronozing,So Is that necessary to have ActiveSync software to be installed in my system,to send mail. Please give me some details,and clarify my doubt. Thanks in advance. – Iyalarasi.R Oct 29 '12 at 04:33
  • The outlook sync function and ActiveSync are different not related things. – josef Oct 29 '12 at 16:37
  • ok..Now I got another problem,I click save state in device emulator,but before it saved I closed it.So now if I deploying application it shows could not read savestate file,Could not connect to the device.Even I uninstall software,And installed it,But It again shows the same error,Can you please tell me that how to solve it?Thanks in Advance. – Iyalarasi.R Oct 30 '12 at 09:44
  • Do you know Internet search engines? Just use "clear device emulator save state" and get this http://msdn.microsoft.com/en-us/library/aa188185%28v=vs.90%29.aspx. A stand alone version of DE is available at http://www.microsoft.com/en-us/download/details.aspx?id=5352. YOU KNOW, that this is not related to your initial question. – josef Oct 30 '12 at 18:27
  • Thank you very much josef,I clear save state file.I know that my question is not releated to my first one.But due to this problem ,I can't able to run your code,It doesn't open emulator,thats why I ask this question. – Iyalarasi.R Oct 31 '12 at 04:37