login about faq


I want to add a header field to an email retrieved from an imap server and save this change back to the server.

This does not do the job: [email AddHeaderField:@"X-name" fieldValue:@"value"];

Do I have to do more or something else?



asked Sep 20 '12 at 17:30

it2be's gravatar image


Messages on an IMAP server are immutable, meaning they cannot be changed. See this from the IMAP specification (RFC):

The combination of mailbox name, UIDVALIDITY, and UID
must refer to a single immutable message on that server
forever.  In particular, the internal date, [RFC-2822]
size, envelope, body structure, and message texts
(RFC822, RFC822.HEADER, RFC822.TEXT, and all BODY[...]
fetch data items) must never change.  This does not
include message numbers, nor does it include attributes
that can be set by a STORE command (e.g., FLAGS).

Also, if the IMAP RFC is reviewed in detail, you'll find there is no IMAP protocol command for replacing an existing email with different content. In other words, once an email is on the server, it cannot be modified.

The only choice is to fetch the email from the server, make modifications, then upload the modified email to the server using any of the following methods: AppendMail, AppendMime, AppendMimeWithDate, or AppendMimeWithFlags, and then finally to delete the original email from the server.


answered Sep 20 '12 at 18:51

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Sep 20 '12 at 17:30

Seen: 2,721 times

Last updated: Sep 20 '12 at 18:51

powered by OSQA