Joshi.Utils.Imap.Imap.CopyMessage C# (CSharp) Method

CopyMessage() public method

Copy Message
public CopyMessage ( string sUid, string sFolderName ) : void
sUid string Either UID or range of uid e.g 1:2
sFolderName string Folder where it needs to be copied
return void
        public void CopyMessage(string sUid, string sFolderName)
        {
            ImapResponseEnum eImapResponse = ImapResponseEnum.IMAP_SUCCESS_RESPONSE;

            if (String.IsNullOrEmpty(sFolderName))
            {
                throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDPARAM, "Invalid folder name.");
            }
            if (String.IsNullOrEmpty(sUid))
            {
                throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDPARAM, "Invalid uid");
            }
            if (!m_bIsLoggedIn)
            {
                try
                {
                    Restore(false);
                }
                catch (ImapException e)
                {
                    if (e.Type != ImapException.ImapErrorEnum.IMAP_ERR_INSUFFICIENT_DATA)
                        throw e;

                    throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_NOTCONNECTED);
                }
            }

            if (!m_bIsFolderSelected && !m_bIsFolderExamined)
            {
                throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_NOTSELECTED);
            }

            ArrayList asResultArray = new ArrayList();
            string sCommand = IMAP_UIDCOPY_COMMAND;
            sCommand += " " + sUid  + " " + sFolderName + IMAP_COMMAND_EOL;
            try
            {
                eImapResponse = SendAndReceive(sCommand, ref asResultArray);
                if (eImapResponse != ImapResponseEnum.IMAP_SUCCESS_RESPONSE)
                {
                    throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_SEARCH, asResultArray[0].ToString());
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }