| Author | 
         | 
         
      
        
         
         WLF2022916 Newbie 
          
  
  Joined: 05 November 2023 Location: United Kingdom
 Online Status: Offline Posts: 10
          | 
        
         
          
           | Posted: 05 November 2023 at 11:56am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Hello
 In most email clients, if we make a new email and save it as eml file without sending, once opened again is available for editing.
 
 But received or sent emails once opened are read-only and can't be edited.
 
 When making a new email message with your mail .net and saving as eml file on disk, which property will control this or how can I set it as editable or read-only?
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         WLF2022916 Newbie 
          
  
  Joined: 05 November 2023 Location: United Kingdom
 Online Status: Offline Posts: 10
          | 
        
         
          
           | Posted: 05 November 2023 at 12:59pm | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Hello
 This works, am I using it correctly?
 MailMessage.Headers.Add("X-Unsent", "1", True)
 
 
 
 
 To remove it (whether it exists or not) is this correct?
 MailMessage.Headers.Remove("X-Unsent")
 
 If X-Unsent is not present, is MailMessage.Headers.Remove("X-Unsent") ignored safely or it may throw exception?
 
 
 
 
 Last concern if you don't mind please?
 Before saving MailMessage, how to add a line to the very beginning of email (the first line)
 I want to add this line to the begin of source MailMessage:
 User-Agent: Microsoft-MacOutlook/16.68
 
 Because it is not started with X- , the below code seems to work but it will not be added to the beginning of MailMessage:
 MailMessage.Headers.Add("User-Agent", "Microsoft-MacOutlook/16.68", True)
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Alex AfterLogic Support 
          
  
  Joined: 19 November 2003
 Online Status: Offline Posts: 2207
          | 
        
         
          
           | Posted: 06 November 2023 at 1:56am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Hi,
 
 EML format does not have read-only status. Mail clients implement this with their own proprietary means.
 
 > MailMessage.Headers.Add("X-Unsent", "1", True)
 It's correct in terms of adding a header. But again, there is no standard mechanism for that. SO it may work with your particular mail client and not with others.
 
 > If X-Unsent is not present, is MailMessage.Headers.Remove("X-Unsent") ignored safely or it may throw exception?
 It's correct and safe. Remove will return False if the header was not found. No exception will be thrown.
 
 > Before saving MailMessage, how to add a line to the very beginning of email (the first line)
 MailMessage.Headers.Add("User-Agent", "Microsoft-MacOutlook/16.68", True, 0)
 
 Regards,
 Alex
 
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   |