| Author | 
         | 
         
      
        
         
         zedekiah Groupie 
          
 
  Joined: 24 June 2009 Location: United States
 Online Status: Offline Posts: 44
          | 
        
         
          
           | Posted: 30 June 2009 at 10:38am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
How do I get the attachment from the envelope?
 Or do I have to go back to the mailserver to get the attachment?
 
  MailBee.Mime.MailMessage msg = imp.DownloadEntireMessage(env.Uid, true);
 
 Is that the only way to get the attachment?
  
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Andrew AfterLogic Support 
          
 
  Joined: 28 April 2006 Location: United States
 Online Status: Offline Posts: 1189
          | 
        
         
          
           | Posted: 01 July 2009 at 12:48am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
There are two ways:
 
 - use Envelope.GetEnvelopeItem method;
 - download envelope with EnvelopeParts.MessagePreview and bodyPreviewSize = -1.
 
 The first way is a bit complex, but downloads only attachment, the second is simpler, but downloads entire message within envelope.
   
 
 Best regards,
 Andrew
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         zedekiah Groupie 
          
 
  Joined: 24 June 2009 Location: United States
 Online Status: Offline Posts: 44
          | 
        
         
          
           | Posted: 02 July 2009 at 5:54am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
The only way I see in the second example is by doing 
  env.MessagePreview.Attachments.SaveAll(@"C:\Temp");
 
 but I need something that will return bytes[]
 like the MailBee.Mime.Attachment.GetData() method.
 
 
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Andrew AfterLogic Support 
          
 
  Joined: 28 April 2006 Location: United States
 Online Status: Offline Posts: 1189
          | 
        
         
          
           | Posted: 02 July 2009 at 6:32am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Try the following:
 
 
Code: 
   
    
    
      
       | byte[] data = env.MessagePreview.Attachments[0].GetData(); | 
       
       | 
    
    | 
 
 
 
 Assuming at least one attachment exists.
 
 Or the following loop:
 
 
Code: 
   
    
    
      
       foreach(Attachment att in env.MessagePreview.Attachments)
 {
    byte[] data = att.GetData();
 } | 
       
       | 
    
    | 
 
 
 
 Best regards,
 Andrew
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   |