title: the method does not exist in the current context
body: <p>My problem is </p>
  
  <p>"Affiche()" does not exist for the current context.</p>
  
  <p>class OPPSVotesStatistiques </p>
  
  <p>The code is below:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Microsoft.SharePoint.Administration;
  using Microsoft.SharePoint;
  using System.Configuration;
  
  
  namespace Components.Jobs
  {
      class OPPSVotesStatistiques : SPJobDefinition
      {
  
          private Pmail p;
  
          public OPPSVotesStatistiques()
              : base()
          {
  
          }    
          public OPPSVotesStatistiques(string jobName, SPWebApplication webApplication)
              : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
          {
              this.Title = "ListLogger";
  
          }
  
          public override void Execute(Guid contentDbId)
          {
             Pmail  p = new Pmail();
             InsretListAvis addAvis = new InsretListAvis();
  
             List&lt;AttributMail&gt; listMail = Pmail.Affiche();
  
             foreach (AttributMail m in listMail)
             {
                 info = addAvis.Insert(m.Projet, m.Phase, m);
        }}}
  
  
  class Pmail
  
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Microsoft.Exchange.WebServices.Data;
  using Microsoft.Exchange.WebServices.Autodiscover;
  using System.Security.Cryptography.X509Certificates;
  using System.Net;
  using System.Text.RegularExpressions;
  
  namespace Components.MailVote
  {
      class Pmail
      {
  
          public Pmail()
          {
          }
  
  
         public static List&lt;AttributMail&gt; Affiche()
          {
              List&lt;AttributMail&gt; lmail = new List&lt;AttributMail&gt;();
  
              try
              {
  
                  ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
                  ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
  
                  //service.Credentials = new NetworkCredential( "{Active Directory ID}", "{Password}", "{Domain Name}" ); 
                  service.Credentials = new WebCredentials("mail@site.com", "pass");
                  service.TraceEnabled = true;
                  service.TraceFlags = TraceFlags.All;
                  service.AutodiscoverUrl("mail@site.com", RedirectionUrlValidationCallback);
  
                  Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
  
  
                  //The search filter to get unread email
  
                  SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
  
                  PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
                  itempropertyset.RequestedBodyType = BodyType.Text;
                  ItemView view = new ItemView(50);
                  view.PropertySet = itempropertyset;
  
                  //Fire the query for the unread items
  
                  FindItemsResults&lt;Item&gt; findResults = service.FindItems(WellKnownFolderName.Inbox, sf, view);
  
                  foreach (Item item in findResults.Items)
                  {
                      AttributMail m = new AttributMail();
                      item.Load(itempropertyset);
                      m.From = (item as EmailMessage).Sender.Name;
                      m.Sujet = item.Subject;
                      m.Txt = item.Body;
                      m.Date = item.DateTimeReceived.TimeOfDay.ToString();
                      m.Cc = item.DisplayCc;
                      lmail.Add(m);
             } }
  catch(Exception ex){
  }
  return lmail;}}}
  </code></pre>
  
  <p>it's a timer job to read mails and to insert data into SPlist .</p>