| Author | 
         | 
         
      
        
         
         scotty Newbie 
          
 
  Joined: 27 August 2007
 Online Status: Offline Posts: 25
          | 
        
         
          
           | Posted: 27 February 2008 at 7:47am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Hi,
 
 For documentation purposes I have to log (to a database) all outgoing emails exactly as they are sent to the SMTP server.
 I tried using GetMessageRawData() afte the message was sent. But repeated calls returned a different result each time. And none was identical to the message-data actually being sent to the SMTP-Server.
 (Among other things the order of the header-properties was changed and the the MimePart – boundary-Parameter was different each time.)
 
 
 Is there a way to get the actual data that is being sent to the SMTP-Server?
 
 Best regards, 
 Scotty
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Alex AfterLogic Support 
          
  
  Joined: 19 November 2003
 Online Status: Offline Posts: 2207
          | 
        
         
          
           | Posted: 27 February 2008 at 10:09am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
GetMessageRawData, if called twice, cannot return different values for each call because it simply returns the cached copy.
 
 Anyway, GetMessageRawData returns exactly what has been passed to the SMTP server. However, if your server processes incoming messages, it can alter them after they have been submitted by MailBee. Most servers do this, at least add Received and Return-Path headers, they can also change boundary in the case of anti-virus or other checks.
 
 Regards,
 Alex
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         scotty Newbie 
          
 
  Joined: 27 August 2007
 Online Status: Offline Posts: 25
          | 
        
         
          
           | Posted: 28 February 2008 at 1:51am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Thank you for your fast response.
 
 I can reproduce the described behaviour every time running the following code:
 
Code: 
   
    
    
      
       
 static void Main(string[] args)
         {
               MailBee.Mime.MailMessage  msg = new MailBee.Mime.MailMessage();
               msg.BodyPlainText = "Testing....";
               msg.From = new EmailAddress("test1@testcenter.com", "Tester1");
               msg.To.Add(new EmailAddress("test2@testcenter.com", "Tester2"));
               msg.Attachments.Add(@"C:\LoremIpsum.doc");  // attaching 28kB Testfile
 
               SaveToFile( msg.GetMessageRawData(), "c:\\MessageRawData1.txt");
               SaveToFile( msg.GetMessageRawData(), "c:\\MessageRawData2.txt");
 }
 
         static private void SaveToFile(byte[] bytes, string fileName)
         {
               FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
               fs.Write(bytes, 0, bytes.Length);
               fs.Close();
         }
  | 
       
       | 
    
    | 
 
 
 
 
 After running the code MessageRawData1.txt contains:
 
 
Code: 
   
    
    
      
       
 MIME-Version: 1.0
 X-Mailer: MailBee.NET 3.0.1.74
 From: "Tester1" <test1@testcenter.com>
 To: "Tester2" <test2@testcenter.com>
 Content-Type: multipart/mixed;
       boundary="----=_NextPart_000_4 E8C_D9F719CB.AF769595"
 
 
 ------=_NextPart_000_4E8C_D9F719CB.AF769595
 Content-Type: text/plain
 Content-Transfer-Encoding: quoted-printable
 
 Testing....
 ------=_NextPart_000_4E8C_D9F719CB.AF769595
 Content-Type: application/msword;
      name="LoremIpsum.doc"
 Content-Disposition: attachment;
      filename="LoremIpsum.doc"
 Content-Transfer-Encoding: base64
 
  0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAB AAAAMQAAAAAAAAAA
  EAAAMwAAAAEAAAD+////AAAAADAAAAD///////////////////////////// ////////////////
  //////////////////////////////////////////////////////////// ///////////////
 
 [......]
  | 
       
       | 
    
    | 
 
 
 
 MessageRawData2.txt contains:
 
 
Code: 
   
    
    
      
       
 To: "Tester2" <test2@testcenter.com>
 From: "Tester1" <test1@testcenter.com>
 X-Mailer: MailBee.NET 3.0.1.74
 MIME-Version: 1.0
 Content-Type: multipart/mixed;
       boundary="----=_NextPart_001_2 244_DE54FDA2.78DE2833"
 
 
 ------=_NextPart_001_2244_DE54FDA2.78DE2833
 Content-Type: text/plain
 Content-Transfer-Encoding: quoted-printable
 
 Testing....
 ------=_NextPart_001_2244_DE54FDA2.78DE2833
 Content-Type: application/msword;
      name="LoremIpsum.doc"
 Content-Disposition: attachment;
      filename="LoremIpsum.doc"
 Content-Transfer-Encoding: base64
 
  0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAAB AAAAMQAAAAAAAAA
 
 [...]
  | 
       
       | 
    
    | 
 
 
 
 I also tried to actually send the message using the following code but aside from adding some header-properties (date) that didn't change anything:
 
 
Code: 
   
    
    
      
       
               Smtp smtp = new Smtp();
               smtp.LowLevelDataSent  += new MailBee.DataTransferEventHandler(smtp_LowLevelDataSent);
               smtp.SmtpServers.Add("mail.mailserver.com");
                smtp.Connect();
 
               smtp.Message = msg;
               smtp.Send();
               smtp.Disconnect();
  
               SaveToFile( msg.GetMessageRawData(), "c:\\MessageRawData1.txt");
               SaveToFile( msg.GetMessageRawData(), "c:\\MessageRawData2.txt");
 
  | 
       
       | 
    
    | 
 
 
 
 Both files contain data that differs from each other and from what is actually send to the server. (Because Servers add stuff to the header of a mail message I used the LowLevelDataSent event to check whats actually send.)
 
 
 What am I doing wrong here?
 
 Best regards, Scotty
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Andrew AfterLogic Support 
          
 
  Joined: 28 April 2006 Location: United States
 Online Status: Offline Posts: 1189
          | 
        
         
          
           | Posted: 28 February 2008 at 10:12am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
We're investigating this now.
 
 Best regards,
 Andrew
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Andrew AfterLogic Support 
          
 
  Joined: 28 April 2006 Location: United States
 Online Status: Offline Posts: 1189
          | 
        
         
          
           | Posted: 03 March 2008 at 3:29am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
We've fixed this. Please refer to this topic of MailBee FAQ to learn how to update your MailBee.NET.dll to the latest version.
 
 Best regards,
 Andrew
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   |