1

I am trying to add an account to E-mail database ,Below is the way i'm trying ...

Account account = new Account(mContext);
account.setDescription("acc added thr prog"); 
account.setAutomaticCheckIntervalMinutes(10);
account.setEmail("UserName@gmail.com");
account.setDraftsFolderName("Drafts");
account.setOutboxFolderName("OutBox");
account.setSentFolderName("Sent");
account.setTrashFolderName("Trash");
account.setName("Tester");
account.setNotifyNewMail(true);
account.setSenderUri("smtp+ssl+://userName@gmail.com:PassWord@imap.gmail.com");
account.setStoreUri("imap+ssl+://userName@gmail.com:PassWord@imap.gmail.com");
account.setDeletePolicy(10);
account.setVibrate(true);
mPrefer = Preferences.getPreferences(getInstrumentation().getContext());
account.save(mPrefer);
Email.setServicesEnabled(mInstrumenatation.getTargetContext());

This code compiles successfully but account will not be created.

Valentin Rocher
  • 11,667
  • 45
  • 59
Santhosh
  • 158
  • 2
  • 14

1 Answers1

-1
    account.setSenderUri(mContext, "smtp+ssl+://UserName%40gmail.com:Password@smtp.gmail.com");
    mAccount.setStoreUri(mContext, "imap+ssl+://UserName%40gmail.com:Password@imap.gmail.com");

These are two important fields that you need add along with the above fields. These Uri's provides a way for your account to connect to internet.

This configuration is for POP3 type of account . If you know similar config for "Exchange account" please inform me , i am waiting for your reply .

Kinds & Regards Santhosh Kumar H.E

Santhosh
  • 158
  • 2
  • 14
  • Hi Santosh, Do you have the complete source code for this. This will help me understand things better – ambit Oct 31 '12 at 12:16