示例#1
0
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table.
        int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed.

        Dictionary<string, Mime> mimes = new Dictionary<string, Mime>();
        List<String> result = new List<String>();

        for (int i = 0; i < N; i++)
        {
            Mime m = new Mime(Console.ReadLine().Split(' '));
            mimes.Add(m.extension.ToUpper(), m);
        }

        for (int i = 0; i < Q; i++)
        {
            Filename entry = new Filename(Console.ReadLine());
            result.Add(entry.ext != String.Empty && mimes.ContainsKey(entry.ext) ? mimes[entry.ext].type : UNKNOWN);
        }

        foreach (string item in result)
        {
            Console.WriteLine(item);
        }
    }
示例#2
0
 public void SetProperty(Mime.ContentDisposition contentDisposition)
 {
     this.Value = contentDisposition.Value;
     this.FileName = contentDisposition.FileName;
     foreach (var p in contentDisposition.Parameters)
     {
         if (String.IsNullOrEmpty(p.Key) == true ||
             String.Equals(p.Key, "filename", StringComparison.OrdinalIgnoreCase) == true)
         { continue; }
         this.Parameters.Add(new SmtpMailHeaderParameter(p.Key, p.Value));
     }
 }
 public void TestProcessMime(Mime m)
 {
     CreateDirectoryPath();
     ProcessMime(m);
 }
示例#4
0
        /// <summary>
        /// Gets if specified message matches with this class search-key.
        /// </summary>
        /// <param name="no">IMAP message sequence number.</param>
        /// <param name="uid">IMAP message UID.</param>
        /// <param name="size">IMAP message size in bytes.</param>
        /// <param name="internalDate">IMAP message INTERNALDATE (dateTime when server stored message).</param>
        /// <param name="flags">IMAP message flags.</param>
        /// <param name="mime">Mime message main header only.</param>
        /// <param name="bodyText">Message body text.</param>
        /// <returns></returns>
        public bool Match(long no,
                          long uid,
                          long size,
                          DateTime internalDate,
                          IMAP_MessageFlags flags,
                          Mime mime,
                          string bodyText)
        {
            #region ALL

            // ALL
            //		All messages in the mailbox; the default initial key for ANDing.
            if (m_SearchKeyName == "ALL")
            {
                return true;
            }

                #endregion

                #region BEFORE

                // BEFORE <date>
                //	Messages whose internal date (disregarding time and timezone)
                //	is earlier than the specified date.
            else if (m_SearchKeyName == "BEFORE")
            {
                if (internalDate.Date < (DateTime) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region BODY

                // BODY <string>
                //	Messages that contain the specified string in the body of the message.
                //
                //	NOTE: Compare must be done on decoded header and decoded body of message.
                //		  In all search keys that use strings, a message matches the key if
                //		  the string is a substring of the field.  The matching is case-insensitive.
            else if (m_SearchKeyName == "BODY")
            {
                string val = bodyText;
                if (val != null && val.ToLower().IndexOf(((string) m_SearchKeyValue).ToLower()) > -1)
                {
                    return true;
                }
            }

                #endregion

                #region HEADER

                // HEADER <field-name> <string>
                //	Messages that have a header with the specified field-name (as
                //	defined in [RFC-2822]) and that contains the specified string
                //	in the text of the header (what comes after the colon).  If the
                //	string to search is zero-length, this matches all messages that
                //	have a header line with the specified field-name regardless of
                //	the contents.
                //
                //	NOTE: Compare must be done on decoded header field value.
                //		  In all search keys that use strings, a message matches the key if
                //		  the string is a substring of the field.  The matching is case-insensitive.
            else if (m_SearchKeyName == "HEADER")
            {
                string[] headerField_value = (string[]) m_SearchKeyValue;

                // If header field name won't end with :, add it
                if (!headerField_value[0].EndsWith(":"))
                {
                    headerField_value[0] = headerField_value[0] + ":";
                }

                if (mime.MainEntity.Header.Contains(headerField_value[0]))
                {
                    if (headerField_value[1].Length == 0)
                    {
                        return true;
                    }
                    else if (
                        mime.MainEntity.Header.GetFirst(headerField_value[0]).Value.ToLower().IndexOf(
                            headerField_value[1].ToLower()) > -1)
                    {
                        return true;
                    }
                }
            }

                #endregion

                #region KEYWORD

                // KEYWORD <flag>
                //	Messages with the specified keyword flag set.
            else if (m_SearchKeyName == "KEYWORD")
            {
                if ((flags & IMAP_Utils.ParseMessageFlags((string) m_SearchKeyValue)) != 0)
                {
                    return true;
                }
            }

                #endregion
				
                #region LARGER
	
                // LARGER <n>
                //	Messages with an [RFC-2822] size larger than the specified number of octets.
            else if (m_SearchKeyName == "LARGER")
            {
                if (size > (long) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region NOT

                //	NOT <search-key> or (<search-key> <search-key> ...)(SearchGroup)
                //		Messages that do not match the specified search key.
            else if (m_SearchKeyName == "NOT")
            {
                return
                    !SearchGroup.Match_Key_Value(m_SearchKeyValue,
                                                 no,
                                                 uid,
                                                 size,
                                                 internalDate,
                                                 flags,
                                                 mime,
                                                 bodyText);
            }

                #endregion

                #region ON

                // ON <date>
                //	Messages whose internal date (disregarding time and timezone)
                //	is within the specified date.
            else if (m_SearchKeyName == "ON")
            {
                if (internalDate.Date == (DateTime) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region OR

                //	OR <search-key1> <search-key2> - SearckKey can be parenthesis list of keys !
                //		Messages that match either search key.
            else if (m_SearchKeyName == "OR")
            {
                object serachKey1 = ((object[]) m_SearchKeyValue)[0];
                object serachKey2 = ((object[]) m_SearchKeyValue)[1];

                if (
                    SearchGroup.Match_Key_Value(serachKey1, no, uid, size, internalDate, flags, mime, bodyText) ||
                    SearchGroup.Match_Key_Value(serachKey2, no, uid, size, internalDate, flags, mime, bodyText))
                {
                    return true;
                }
            }

                #endregion

                #region SENTBEFORE

                // SENTBEFORE <date>
                //	Messages whose [RFC-2822] Date: header (disregarding time and
                //	timezone) is earlier than the specified date.
            else if (m_SearchKeyName == "SENTBEFORE")
            {
                if (mime.MainEntity.Date.Date < (DateTime) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region SENTON

                // SENTON <date>
                //	Messages whose [RFC-2822] Date: header (disregarding time and
                //	timezone) is within the specified date.
            else if (m_SearchKeyName == "SENTON")
            {
                if (mime.MainEntity.Date.Date == (DateTime) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region SENTSINCE

                // SENTSINCE <date>
                //	Messages whose [RFC-2822] Date: header (disregarding time and
                //	timezone) is within or later than the specified date.
            else if (m_SearchKeyName == "SENTSINCE")
            {
                if (mime.MainEntity.Date.Date >= (DateTime) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region SINCE

                // SINCE <date>
                //	Messages whose internal date (disregarding time and timezone)
                //	is within or later than the specified date.	
            else if (m_SearchKeyName == "SINCE")
            {
                if (internalDate.Date >= (DateTime) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region SMALLER

                // SMALLER <n>
                //	Messages with an [RFC-2822] size smaller than the specified	number of octets.
            else if (m_SearchKeyName == "SMALLER")
            {
                if (size < (long) m_SearchKeyValue)
                {
                    return true;
                }
            }

                #endregion

                #region TEXT

                // TEXT <string>
                //	Messages that contain the specified string in the header or	body of the message.
                //
                //  NOTE: Compare must be done on decoded header and decoded body of message.
                //		  In all search keys that use strings, a message matches the key if
                //		  the string is a substring of the field.  The matching is case-insensitive.
            else if (m_SearchKeyName == "TEXT")
            {
                // See body first
                string val = bodyText;
                if (val != null && val.ToLower().IndexOf(((string) m_SearchKeyValue).ToLower()) > -1)
                {
                    return true;
                }

                // If we reach so far, that means body won't contain specified text and we need to check header.
                foreach (HeaderField headerField in mime.MainEntity.Header)
                {
                    if (headerField.Value.ToLower().IndexOf(((string) m_SearchKeyValue).ToLower()) > -1)
                    {
                        return true;
                    }
                }
            }

                #endregion

                #region UID

                // UID <sequence set>
                //	Messages with unique identifiers corresponding to the specified
                //	unique identifier set.  Sequence set ranges are permitted.
            else if (m_SearchKeyName == "UID")
            {
                return ((IMAP_SequenceSet) m_SearchKeyValue).Contains(uid);
            }

                #endregion

                #region UNKEYWORD

                // UNKEYWORD <flag>
                //	Messages that do not have the specified keyword flag set.
            else if (m_SearchKeyName == "UNKEYWORD")
            {
                if ((flags & IMAP_Utils.ParseMessageFlags((string) m_SearchKeyValue)) == 0)
                {
                    return true;
                }
            }

                #endregion

                #region SEQUENCESET

                // <sequence set>
                //		Messages with message sequence numbers corresponding to the
                //		specified message sequence number set.
            else if (m_SearchKeyName == "SEQUENCESET")
            {
                return ((IMAP_SequenceSet) m_SearchKeyValue).Contains(no);
            }

            #endregion

            return false;
        }
示例#5
0
 /// <summary>
 /// Sends specified message to specified smart host.
 /// </summary>
 /// <param name="smartHost">Smarthost name or IP.</param>
 /// <param name="port">SMTP port number. Normally this is 25.</param>
 /// <param name="hostName">Host name reported to SMTP server.</param>
 /// <param name="message">Mime message to send.</param>
 public static void QuickSendSmartHost(string smartHost, int port, string hostName, Mime message)
 {
     QuickSendSmartHost(smartHost, port, hostName, "", "", message);
 }
示例#6
0
 public void UrlsWithQmAndHash()
 {
     Assert.AreEqual(Mime.MimeTypes["jpg"], Mime.DetectImageMime("xyz/abc/def.jpg?w=200#awesome"));
 }
示例#7
0
 protected abstract Task OnConvertAsync(string srcFilePath, Mime srcMime, string dstFilePath, ImageModifier dstImgMod, TaskContext taskCtx);
        /// <summary>
        /// Gets if specified values match search criteria.
        /// </summary>
        /// <param name="no">Message sequence number.</param>
        /// <param name="uid">Message UID.</param>
        /// <param name="size">Message size in bytes.</param>
        /// <param name="internalDate">Message INTERNALDATE (dateTime when server stored message).</param>
        /// <param name="flags">Message flags.</param>
        /// <param name="header">Message header. This is only needed if this.IsHeaderNeeded is true.</param>
        /// <param name="bodyText">Message body text (must be decoded unicode text). This is only needed if this.IsBodyTextNeeded is true.</param>
        /// <returns></returns>
        public bool Matches(int no,
                            int uid,
                            int size,
                            DateTime internalDate,
                            IMAP_MessageFlags flags,
                            string header,
                            string bodyText)
        {
            // Parse header only if it's needed
            Mime m = null;
            if (m_pSearchCriteria.IsHeaderNeeded())
            {
                m = new Mime();
                m.MainEntity.Header.Parse(header);
            }

            return m_pSearchCriteria.Match(no, uid, size, internalDate, flags, m, bodyText);
        }
示例#9
0
 public override string GetBody(Mime mime)
 {
     return(string.Format(MailTemplate.Body, mime.MainEntity.Subject, ErrorExtention, AllowedExtensions));
 }
示例#10
0
        /// <summary>
        /// This function pre processes the EML <see cref="Mime.Message"/> object, it tries to find the html (or text) body
        /// and reads all the available <see cref="Mime.MessagePart">attachment</see> objects. When an attachment is inline it tries to
        /// map this attachment to the html body part when this is available
        /// </summary>
        /// <param name="message">The <see cref="Mime.Message"/> object</param>
        /// <param name="hyperlinks">When true then hyperlinks are generated for the To, CC, BCC and 
        /// attachments (when there is an html body)</param>
        /// <param name="outputFolder">The outputfolder where alle extracted files need to be written</param>
        /// <param name="fileName">Returns the filename for the html or text body</param>
        /// <param name="htmlBody">Returns true when the <see cref="Mime.Message"/> object did contain 
        /// an HTML body</param>
        /// <param name="body">Returns the html or text body</param>
        /// <param name="attachments">Returns a list of names with the found attachment</param>
        /// <param name="files">Returns all the files that are generated after pre processing the <see cref="Mime.Message"/> object</param>
        private static void PreProcessEmlFile(Mime.Message message,
            bool hyperlinks,
            string outputFolder,
            ref string fileName,
            out bool htmlBody,
            out string body,
            out List<string> attachments,
            out List<string> files)
        {
            attachments = new List<string>();
            files = new List<string>();

            var bodyMessagePart = message.HtmlBody;

            if (bodyMessagePart != null)
            {
                body = bodyMessagePart.GetBodyAsText();
                htmlBody = true;
            }
            else
            {
                bodyMessagePart = message.TextBody;

                // When there is no body at all we just make an empty html document
                if (bodyMessagePart != null)
                {
                    body = bodyMessagePart.GetBodyAsText();
                    htmlBody = false;
                }
                else
                {
                    htmlBody = true;
                    body = "<html><head></head><body></body></html>";
                }
            }

            fileName = outputFolder +
                       (!string.IsNullOrEmpty(message.Headers.Subject)
                           ? FileManager.RemoveInvalidFileNameChars(message.Headers.Subject)
                           : fileName) + (htmlBody ? ".htm" : ".txt");

            fileName = FileManager.FileExistsMakeNew(fileName);
            files.Add(fileName);

            if (message.Attachments != null)
            {
                foreach (var attachment in message.Attachments)
                {
                    var attachmentFileName = attachment.FileName;
                    var fileInfo = new FileInfo(FileManager.FileExistsMakeNew(outputFolder + attachmentFileName));
                    File.WriteAllBytes(fileInfo.FullName, attachment.Body);

                    // When we find an inline attachment we have to replace the CID tag inside the html body
                    // with the name of the inline attachment. But before we do this we check if the CID exists.
                    // When the CID does not exists we treat the inline attachment as a normal attachment
                    if (htmlBody && !string.IsNullOrEmpty(attachment.ContentId) && body.Contains(attachment.ContentId))
                    {
                        body = body.Replace("cid:" + attachment.ContentId, fileInfo.FullName);
                    }
                    else
                    {
                        // If we didn't find the cid tag we treat the inline attachment as a normal one 

                        files.Add(fileInfo.FullName);

                        if (htmlBody)
                        {
                            if (hyperlinks)
                                attachments.Add("<a href=\"" + fileInfo.Name + "\">" +
                                                HttpUtility.HtmlEncode(attachmentFileName) + "</a> (" +
                                                FileManager.GetFileSizeString(fileInfo.Length) + ")");
                            else
                                attachments.Add(HttpUtility.HtmlEncode(attachmentFileName) + " (" +
                                                FileManager.GetFileSizeString(fileInfo.Length) + ")");
                        }
                        else
                            attachments.Add(attachmentFileName + " (" + FileManager.GetFileSizeString(fileInfo.Length) + ")");
                    }
                }
            }
        }
示例#11
0
        private Mime CreateMessage()
        {
            Mime m = new Mime();
            MimeEntity texts_enity = null;
            MimeEntity attachments_entity = null;

            ///Văn bản
            if (pathFile.Text.Trim()!=string.Empty)
            {
                m.MainEntity.ContentType = MediaType_enum.Multipart_mixed;
                texts_enity = m.MainEntity.ChildEntities.Add();
                texts_enity.ContentType = MediaType_enum.Multipart_alternative;
                attachments_entity = m.MainEntity;

                MimeEntity attachment_entity = attachments_entity.ChildEntities.Add();
                attachment_entity.ContentType = MediaType_enum.Application_octet_stream;
                attachment_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
                attachment_entity.ContentDisposition = ContentDisposition_enum.Attachment;
                attachment_entity.ContentDisposition_FileName = Path.GetFileName(pathFile.Text);
                attachment_entity.Data = File.ReadAllBytes(pathFile.Text);
            }
            else {
                m.MainEntity.ContentType = MediaType_enum.Multipart_alternative;
                texts_enity = m.MainEntity;
            }

            ///Thông tin mail
            m.MainEntity.From = this.GetAddressList(new long[] {this.cmbFrom._getSelectedID()});
            m.MainEntity.To = this.GetAddressList(cmbTo._getSelectedIDs());
            m.MainEntity.Subject = this.textSubject.Text;
            if (cmbCC._getSelectedIDs().Length > 0)
            {
                m.MainEntity.Cc = this.GetAddressList(cmbCC._getSelectedIDs());
            }
            m.MainEntity.Bcc = this.GetAddressList(new long[] { this.cmbFrom._getSelectedID() });

            ///Nội dung
            MimeEntity text_entity = texts_enity.ChildEntities.Add();
            text_entity.ContentType = MediaType_enum.Text_plain;
            text_entity.ContentType_CharSet = "utf-8";
            text_entity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
            text_entity.DataText = this.PLNoidung._getHTMLText();

            MimeEntity rtfText_entity = texts_enity.ChildEntities.Add();
            rtfText_entity.ContentType = MediaType_enum.Text_html;
            rtfText_entity.ContentType_CharSet = "utf-8";
            rtfText_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
            rtfText_entity.DataText = this.PLNoidung._getHTMLText();

            return m;
        }
示例#12
0
        public void SetProperty(Mime.ContentType contentType)
        {
            var ct = this;

            ct.Value = contentType.Value;
            ct.Boundary = contentType.Boundary;
            var encoding = TryCreateEncoding(contentType.Charset);
            if (encoding != null)
            {
                ct.CharsetEncoding = encoding;
            }
            foreach (var p in contentType.Parameters)
            {
                if (String.IsNullOrEmpty(p.Key) == true ||
                    String.Equals(p.Key, "name", StringComparison.OrdinalIgnoreCase) == true ||
                    String.Equals(p.Key, "boundary", StringComparison.OrdinalIgnoreCase) == true)
                { continue; }
                ct.Parameters.Add(new SmtpMailHeaderParameter(p.Key, p.Value));
            }
        }
        /// <summary>
        /// Creates Mime message based on UI data.
        /// </summary>
        private Mime CreateMessage()
        {
            Mime m = new Mime();

            MimeEntity texts_enity        = null;
            MimeEntity attachments_entity = null;
            if(m_pAttachments.Items.Count > 0){
                m.MainEntity.ContentType = MediaType_enum.Multipart_mixed;
                texts_enity = m.MainEntity.ChildEntities.Add();
                texts_enity.ContentType = MediaType_enum.Multipart_alternative;

                attachments_entity = m.MainEntity;
            }
            else{
                m.MainEntity.ContentType = MediaType_enum.Multipart_alternative;
                texts_enity = m.MainEntity;
            }

            // Main entity settings
            AddressList from = new AddressList();
            from.Parse(m_pFrom.Text);
            m.MainEntity.From = from;
            AddressList to = new AddressList();
            to.Parse("\"" + m_pFolder.User.FullName + "\" <" + m_pFolder.User.FullName + "@localhost>");
            m.MainEntity.To = to;
            m.MainEntity.Subject = m_pSubject.Text;

            // Create text/plain entity
            MimeEntity text_entity = texts_enity.ChildEntities.Add();
            text_entity.ContentType = MediaType_enum.Text_plain;
            text_entity.ContentType_CharSet = "utf-8";
            text_entity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
            text_entity.DataText = m_pText.Text;

            // Create text/rtf entity
            MimeEntity rtfText_entity = texts_enity.ChildEntities.Add();
            rtfText_entity.ContentType = MediaType_enum.Text_html;
            rtfText_entity.ContentType_CharSet = "utf-8";
            rtfText_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
            rtfText_entity.DataText = RtfToHtml();

            // Create attachment etities
            if(attachments_entity != null){
                foreach(ListViewItem item in m_pAttachments.Items){
                    MimeEntity attachment_entity = attachments_entity.ChildEntities.Add();
                    attachment_entity.ContentType = MediaType_enum.Application_octet_stream;
                    attachment_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
                    attachment_entity.ContentDisposition = ContentDisposition_enum.Attachment;
                    attachment_entity.ContentDisposition_FileName = Path.GetFileName(item.Tag.ToString());
                    attachment_entity.Data = File.ReadAllBytes(item.Tag.ToString());
                }
            }

            return m;
        }
示例#14
0
 public MimeSignature(int offset, byte[] data, Mime mime)
 {
     Offset = offset;
     Data = data;
     Mime = mime;
 }
示例#15
0
 public static MimeSignature FromAnsi(string text, Mime mime)
     => new MimeSignature(0, new byte[0], mime);
示例#16
0
 public override string GetBody(Mime mime)
 {
     return(MailTemplate.Body);
 }
示例#17
0
 public override string GetBody(Mime mime)
 {
     return(string.Format(MailTemplate.Body, mime.MainEntity.Subject, CauseList));
 }
示例#18
0
        /// <summary>
        /// Writes the body of the EML E-mail to html or text and extracts all the attachments. The
        /// result is returned as a List of strings
        /// </summary>
        /// <param name="message">The <see cref="Mime.Message"/> object</param>
        /// <param name="outputFolder">The folder where we need to write the output</param>
        /// <param name="hyperlinks">When true then hyperlinks are generated for the To, CC, BCC and attachments</param>
        /// <returns></returns>
        private List<string> WriteEmlEmail(Mime.Message message, string outputFolder, bool hyperlinks)
        {
            var fileName = "email";
            bool htmlBody;
            string body;
            List<string> attachmentList;
            List<string> files;

            PreProcessEmlFile(message,
                hyperlinks,
                outputFolder,
                ref fileName,
                out htmlBody,
                out body,
                out attachmentList,
                out files);

            if (!htmlBody)
                hyperlinks = false;

            var maxLength = 0;

            // Calculate padding width when we are going to write a text file
            if (!htmlBody)
            {
                var languageConsts = new List<string>
                {
                    #region LanguageConsts
                    LanguageConsts.EmailFromLabel,
                    LanguageConsts.EmailSentOnLabel,
                    LanguageConsts.EmailToLabel,
                    LanguageConsts.EmailCcLabel,
                    LanguageConsts.EmailBccLabel,
                    LanguageConsts.EmailSubjectLabel,
                    LanguageConsts.ImportanceLabel,
                    LanguageConsts.EmailAttachmentsLabel,
                    #endregion
                };

                maxLength = languageConsts.Select(languageConst => languageConst.Length).Concat(new[] { 0 }).Max() + 2;
            }

            var emailHeader = new StringBuilder();

            var headers = message.Headers;

            // Start of table
            WriteHeaderStart(emailHeader, htmlBody);

            // From
            var from = string.Empty;
            if (headers.From != null)
                from = message.GetEmailAddresses(new List<RfcMailAddress> { headers.From }, hyperlinks, htmlBody);

            WriteHeaderLineNoEncoding(emailHeader, htmlBody, maxLength, LanguageConsts.EmailFromLabel, from);

            // Sent on
            WriteHeaderLine(emailHeader, htmlBody, maxLength, LanguageConsts.EmailSentOnLabel,
                (message.Headers.DateSent.ToLocalTime()).ToString(LanguageConsts.DataFormatWithTime));

            // To
            WriteHeaderLineNoEncoding(emailHeader, htmlBody, maxLength, LanguageConsts.EmailToLabel,
                message.GetEmailAddresses(headers.To, hyperlinks, htmlBody));

            // CC
            var cc = message.GetEmailAddresses(headers.Cc, hyperlinks, htmlBody);
            if (!string.IsNullOrEmpty(cc))
                WriteHeaderLineNoEncoding(emailHeader, htmlBody, maxLength, LanguageConsts.EmailCcLabel, cc);

            // BCC
            var bcc = message.GetEmailAddresses(headers.Bcc, hyperlinks, htmlBody);
            if (!string.IsNullOrEmpty(bcc))
                WriteHeaderLineNoEncoding(emailHeader, htmlBody, maxLength, LanguageConsts.EmailBccLabel, bcc);

            // Subject
            var subject = message.Headers.Subject ?? string.Empty;
            WriteHeaderLine(emailHeader, htmlBody, maxLength, LanguageConsts.EmailSubjectLabel, subject);

            // Urgent
            var importanceText = string.Empty;
            switch (message.Headers.Importance)
            {
                case MailPriority.Low:
                    importanceText = LanguageConsts.ImportanceLowText;
                    break;

                case MailPriority.Normal:
                    importanceText = LanguageConsts.ImportanceNormalText;
                    break;

                case MailPriority.High:
                    importanceText = LanguageConsts.ImportanceHighText;
                    break;
            }

            if (!string.IsNullOrEmpty(importanceText))
            {
                WriteHeaderLine(emailHeader, htmlBody, maxLength, LanguageConsts.ImportanceLabel, importanceText);

                // Empty line
                WriteHeaderEmptyLine(emailHeader, htmlBody);
            }

            // Attachments
            if (attachmentList.Count != 0)
                WriteHeaderLineNoEncoding(emailHeader, htmlBody, maxLength, LanguageConsts.EmailAttachmentsLabel,
                    string.Join(", ", attachmentList));

            // Empty line
            WriteHeaderEmptyLine(emailHeader, htmlBody);

            // End of table + empty line
            WriteHeaderEnd(emailHeader, htmlBody);

            body = InjectHeader(body, emailHeader.ToString());

            // Write the body to a file
            File.WriteAllText(fileName, body, Encoding.UTF8);

            return files;
        }
示例#19
0
        /// <summary>
        /// Sends specified mime message.
        /// </summary>
        /// <param name="message">Message to send.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>message</b> is null.</exception>
        public static void QuickSend(Mime message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            string from = "";
            if (message.MainEntity.From != null && message.MainEntity.From.Count > 0)
            {
                from = ((MailboxAddress) message.MainEntity.From[0]).EmailAddress;
            }

            List<string> recipients = new List<string>();
            if (message.MainEntity.To != null)
            {
                MailboxAddress[] addresses = message.MainEntity.To.Mailboxes;
                foreach (MailboxAddress address in addresses)
                {
                    recipients.Add(address.EmailAddress);
                }
            }
            if (message.MainEntity.Cc != null)
            {
                MailboxAddress[] addresses = message.MainEntity.Cc.Mailboxes;
                foreach (MailboxAddress address in addresses)
                {
                    recipients.Add(address.EmailAddress);
                }
            }
            if (message.MainEntity.Bcc != null)
            {
                MailboxAddress[] addresses = message.MainEntity.Bcc.Mailboxes;
                foreach (MailboxAddress address in addresses)
                {
                    recipients.Add(address.EmailAddress);
                }

                // We must hide BCC
                message.MainEntity.Bcc.Clear();
            }

            foreach (string recipient in recipients)
            {
                QuickSend(null, from, recipient, new MemoryStream(message.ToByteData()));
            }
        }
示例#20
0
        private Mime CreateMessage()
        {
            Mime m = new Mime();
            MimeEntity texts_enity = null;
            MimeEntity attachments_entity = null;

            //Văn bản
            if (plMultiChoiceFiles1._DataSource != null)
                plMultiChoiceFiles1._DataSource.AcceptChanges();
            if (plMultiChoiceFiles1._DataSource != null && plMultiChoiceFiles1._DataSource.Tables.Count > 0 && plMultiChoiceFiles1._DataSource.Tables[0].Rows.Count > 0)
            {
                m.MainEntity.ContentType = MediaType_enum.Multipart_mixed;
                texts_enity = m.MainEntity.ChildEntities.Add();
                texts_enity.ContentType = MediaType_enum.Multipart_alternative;
                attachments_entity = m.MainEntity;
                foreach (DataRow row in plMultiChoiceFiles1._DataSource.Tables[0].Rows)
                {
                    MimeEntity attachment_entity = attachments_entity.ChildEntities.Add();
                    attachment_entity.ContentType = MediaType_enum.Application_octet_stream;
                    attachment_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
                    attachment_entity.ContentDisposition = ContentDisposition_enum.Attachment;
                    attachment_entity.ContentDisposition_FileName = row["TEN_FILE"].ToString();
                    attachment_entity.Data = (byte[])row["NOI_DUNG"];
                }
            }
            else
            {
                m.MainEntity.ContentType = MediaType_enum.Multipart_alternative;
                texts_enity = m.MainEntity;
            }

            ///Thông tin mail
            m.MainEntity.From = EmailNguoiGui;
            m.MainEntity.To = EmailNguoiNhan;
            m.MainEntity.Subject = this.textSubject.Text;

            ///Nội dung
            ///
            string html= this.NoiDung.richEditControl.HtmlText;
            html = html.Insert(html.IndexOf("</body>"),
              "<br>____________________________</br><br><i>"
              + HelpAutoOpenForm.GeneratingCodeFromForm(formClass, IDPhieu) + "<i><br>");
            MimeEntity text_entity = texts_enity.ChildEntities.Add();
            text_entity.ContentType = MediaType_enum.Text_plain;
            text_entity.ContentType_CharSet = "utf-8";
            text_entity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
            text_entity.DataText =html;

            MimeEntity rtfText_entity = texts_enity.ChildEntities.Add();
            rtfText_entity.ContentType = MediaType_enum.Text_html;
            rtfText_entity.ContentType_CharSet = "utf-8";
            rtfText_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
            rtfText_entity.DataText = html;
            return m;
        }
示例#21
0
        /// <summary>
        /// 创建Mime类型格式邮件
        /// </summary>
        /// <param name="tomails"></param>
        /// <param name="ccmails"></param>
        /// <param name="mailFrom"></param>
        /// <param name="mailFromDisplay"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="attachments"></param>
        /// <param name="embedImages"></param>
        /// <param name="notifyEmail"></param>
        /// <param name="plaintTextTips"></param>
        /// <param name="replyEmail"></param>
        /// <returns></returns>
        public static Mime Create_HtmlBody_Attachment_Image(Dictionary <string, string> tomails, Dictionary <string, string> ccmails,
                                                            string mailFrom, string mailFromDisplay, string subject, string body, List <string> attachments,
                                                            Dictionary <string, string> embedImages, string notifyEmail = "", string plaintTextTips = "", string replyEmail = "")
        {
            Mime       m          = new Mime();
            MimeEntity mainEntity = m.MainEntity;

            #region 设置收件箱
            if (tomails != null)
            {
                mainEntity.To = new AddressList();
                foreach (string address in tomails.Keys)
                {
                    string displayName = tomails[address];
                    mainEntity.To.Add(new MailboxAddress(displayName, address));
                }
            }
            #endregion

            #region 设置抄送箱
            if (ccmails != null)
            {
                mainEntity.Cc = new AddressList();
                foreach (string address in ccmails.Keys)
                {
                    string displayName = ccmails[address];
                    mainEntity.Cc.Add(new MailboxAddress(displayName, address));
                }
            }
            #endregion

            #region 设置发件箱
            if (!string.IsNullOrWhiteSpace(mailFrom))
            {
                mainEntity.From = new AddressList();
                mainEntity.From.Add(new MailboxAddress(mailFromDisplay, mailFrom));
            }
            #endregion

            mainEntity.Subject     = subject;
            mainEntity.ContentType = MediaType_enum.Multipart_mixed;

            #region 设置回执通知
            if (!string.IsNullOrEmpty(notifyEmail) && IsEmail(notifyEmail))
            {
                mainEntity.DSN = notifyEmail;
            }
            #endregion

            MimeEntity textEntity = mainEntity.ChildEntities.Add();
            textEntity.ContentType             = MediaType_enum.Text_html;
            textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
            textEntity.DataText = body;

            //附件
            foreach (string attach in attachments)
            {
                MimeEntity attachmentEntity = mainEntity.ChildEntities.Add();
                attachmentEntity.ContentType             = MediaType_enum.Application_octet_stream;
                attachmentEntity.ContentDisposition      = ContentDisposition_enum.Attachment;
                attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
                FileInfo file = new FileInfo(attach);
                attachmentEntity.ContentDisposition_FileName = file.Name;
                attachmentEntity.DataFromFile(attach);
            }

            //嵌入图片
            foreach (string key in embedImages.Keys)
            {
                MimeEntity attachmentEntity = mainEntity.ChildEntities.Add();
                attachmentEntity.ContentType             = MediaType_enum.Application_octet_stream;
                attachmentEntity.ContentDisposition      = ContentDisposition_enum.Inline;
                attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
                string   imageFile = embedImages[key];
                FileInfo file      = new FileInfo(imageFile);
                attachmentEntity.ContentDisposition_FileName = file.Name;

                //string displayName = Path.GetFileNameWithoutExtension(fileName);
                attachmentEntity.ContentID = key;//BytesTools.BytesToHex(Encoding.Default.GetBytes(fileName));

                attachmentEntity.DataFromFile(imageFile);
            }
            return(m);
        }
 public IHttpBuilder Mime(Mime mime) => Set(() => _mime = mime.GetAlias());
示例#23
0
 public void UrlsWithQuestionMark()
 {
     Assert.AreEqual(Mime.MimeTypes["jpg"], Mime.DetectImageMime("xyz/abc/def.jpg?w=200"));
 }
示例#24
0
 public void Text()
 {
     Mime.Get("../../App_Data/Text.txt").ShouldNotBe(ApplicationOctetStream);
     Mime.Get("../../App_Data/Text.txt").ShouldBe("application/text");
 }
        public void htm_extension_is_correctly_identified()
        {
            var result = Mime.Lookup("test.htm");

            result.Should().Be("text/html");
        }
        /// <summary>
        /// Gets if specified message matches with this class search-key.
        /// </summary>
        /// <param name="no">IMAP message sequence number.</param>
        /// <param name="uid">IMAP message UID.</param>
        /// <param name="size">IMAP message size in bytes.</param>
        /// <param name="internalDate">IMAP message INTERNALDATE (dateTime when server stored message).</param>
        /// <param name="flags">IMAP message flags.</param>
        /// <param name="mime">Mime message main header only.</param>
        /// <param name="bodyText">Message body text.</param>
        /// <returns></returns>
        public bool Match(long no,
                          long uid,
                          long size,
                          DateTime internalDate,
                          IMAP_MessageFlags flags,
                          Mime mime,
                          string bodyText)
        {
            // We must match all keys, if one fails, no need to check others

            foreach (object searckKey in m_pSearchKeys)
            {
                if (!Match_Key_Value(searckKey, no, uid, size, internalDate, flags, mime, bodyText))
                {
                    return false;
                }
            }

            return true;
        }
示例#27
0
        /// <summary>
        /// Sends specified message to specified smart host.
        /// </summary>
        /// <param name="smartHost">Smarthost name or IP.</param>
        /// <param name="port">SMTP port number. Default SMTP port is 25 and SSL port is 465.</param>
        /// <param name="ssl">Specifies if to connected via SSL.</param>
        /// <param name="hostName">Host name reported to SMTP server.</param>
        /// <param name="userName">SMTP user name. Note: Pass empty string if no authentication wanted.</param>
        /// <param name="password">SMTP password.</param>
        /// <param name="message">Mime message to send.</param>
        public static void QuickSendSmartHost(string smartHost,
                                              int port,
                                              bool ssl,
                                              string hostName,
                                              string userName,
                                              string password,
                                              Mime message)
        {
            string from = "";
            if (message.MainEntity.From != null)
            {
                MailboxAddress[] addresses = message.MainEntity.From.Mailboxes;
                if (addresses.Length > 0)
                {
                    from = addresses[0].EmailAddress;
                }
            }

            ArrayList recipients = new ArrayList();
            if (message.MainEntity.To != null)
            {
                MailboxAddress[] addresses = message.MainEntity.To.Mailboxes;
                foreach (MailboxAddress address in addresses)
                {
                    recipients.Add(address.EmailAddress);
                }
            }
            if (message.MainEntity.Cc != null)
            {
                MailboxAddress[] addresses = message.MainEntity.Cc.Mailboxes;
                foreach (MailboxAddress address in addresses)
                {
                    recipients.Add(address.EmailAddress);
                }
            }
            if (message.MainEntity.Bcc != null)
            {
                MailboxAddress[] addresses = message.MainEntity.Bcc.Mailboxes;
                foreach (MailboxAddress address in addresses)
                {
                    recipients.Add(address.EmailAddress);
                }
            }
            string[] to = new string[recipients.Count];
            recipients.CopyTo(to);

            MemoryStream messageStream = new MemoryStream();
            message.ToStream(messageStream);
            messageStream.Position = 0;

            // messageStream
            QuickSendSmartHost(smartHost, port, ssl, hostName, userName, password, from, to, messageStream);
        }
        /// <summary>
        /// Gets if specified message matches to specified search key.
        /// </summary>
        /// <param name="searchKey">SearchKey or SearchGroup.</param>
        /// <param name="no">IMAP message sequence number.</param>
        /// <param name="uid">IMAP message UID.</param>
        /// <param name="size">IMAP message size in bytes.</param>
        /// <param name="internalDate">IMAP message INTERNALDATE (dateTime when server stored message).</param>
        /// <param name="flags">IMAP message flags.</param>
        /// <param name="mime">Mime message main header only.</param>
        /// <param name="bodyText">Message body text.</param>
        /// <returns></returns>
        internal static bool Match_Key_Value(object searchKey,
                                             long no,
                                             long uid,
                                             long size,
                                             DateTime internalDate,
                                             IMAP_MessageFlags flags,
                                             Mime mime,
                                             string bodyText)
        {
            if (searchKey.GetType() == typeof (SearchKey))
            {
                if (!((SearchKey) searchKey).Match(no, uid, size, internalDate, flags, mime, bodyText))
                {
                    return false;
                }
            }
            else if (searchKey.GetType() == typeof (SearchGroup))
            {
                if (!((SearchGroup) searchKey).Match(no, uid, size, internalDate, flags, mime, bodyText))
                {
                    return false;
                }
            }

            return true;
        }
示例#29
0
 public static MimeSignature FromHex(int offset, string text, Mime mime)
     => new MimeSignature(0, new byte[0], mime);
示例#30
0
        public static string SendEmail(string to, string cc, string bcc, string subject, string msg, string files)
        {
            string err = "";

            string[] filea = files.Split(new char[] { ',' });

            //if (filea.Length > batchSize)
            //{
            //    return SendEmailSplit(to, cc, bcc, subject, msg, files);
            //}
            string[] SMTPCONFIG = System.Configuration.ConfigurationManager.AppSettings["SMTP"].Split(new char[] { '|' });
            string   smtp_host  = SMTPCONFIG[0];
            int      smtp_port  = int.Parse(SMTPCONFIG[1]);
            bool     smtp_ssl   = SMTPCONFIG[2] == "SSL";
            string   smtp_user  = SMTPCONFIG[3];
            string   smtp_pass  = SMTPCONFIG[4];
            string   smtp_name  = SMTPCONFIG[5];


            Mime mail = new Mime();

            mail.MainEntity.From = new AddressList();
            mail.MainEntity.From.Parse(smtp_name + "<" + smtp_user + ">");
            mail.MainEntity.Subject     = subject;
            mail.MainEntity.ContentType = MediaType_enum.Multipart_mixed;

            mail.MainEntity.To = new AddressList();
            string[] toa = to.Split(new char[] { ',', ';', '/' });
            for (int i = 0; i < toa.Length; i++)
            {
                string eaddr = toa[i].Trim();
                if (eaddr.Length > 8 && eaddr.IndexOf("@") > 2)
                {
                    mail.MainEntity.To.Parse(eaddr);
                }
            }
            mail.MainEntity.Cc = new AddressList();
            string[] cca = cc.Split(new char[] { ',', ';', '/' });
            for (int i = 0; i < cca.Length; i++)
            {
                string eaddr = cca[i].Trim();
                if (eaddr.Length > 8 && eaddr.IndexOf("@") > 2)
                {
                    mail.MainEntity.Cc.Parse(eaddr);
                }
            }
            mail.MainEntity.Bcc = new AddressList();
            string[] bcca = bcc.Split(new char[] { ',', ';', '/' });
            for (int i = 0; i < bcca.Length; i++)
            {
                string eaddr = bcca[i].Trim();
                if (eaddr.Length > 8 && eaddr.IndexOf("@") > 2)
                {
                    mail.MainEntity.Bcc.Parse(eaddr);
                }
            }
            MimeEntity textEntity = mail.MainEntity.ChildEntities.Add();

            textEntity.ContentType             = MediaType_enum.Text_html;//Text_plain;
            textEntity.ContentType_CharSet     = "utf-8";
            textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
            textEntity.DataText = msg;
            try
            {
                for (int i = 0; i < filea.Length; i++)
                {
                    string file      = filea[i];
                    string parthFile = HttpContext.Current.Server.MapPath(file);
                    if (File.Exists(parthFile))
                    {
                        string     filename         = file.Substring(file.LastIndexOf("\\") + 1);
                        MimeEntity attachmentEntity = mail.MainEntity.ChildEntities.Add();
                        attachmentEntity.ContentType                 = MediaType_enum.Application_octet_stream;
                        attachmentEntity.ContentDisposition          = ContentDisposition_enum.Attachment;
                        attachmentEntity.ContentTransferEncoding     = ContentTransferEncoding_enum.Base64;
                        attachmentEntity.ContentDisposition_FileName = filename;
                        attachmentEntity.Data = (byte[])File.ReadAllBytes(parthFile);
                    }
                }
                LumiSoft.Net.SMTP.Client.SmtpClientEx.QuickSendSmartHost(smtp_host, smtp_port, smtp_ssl, "", smtp_user, smtp_pass, mail);
            }
            catch (Exception ex)
            {
                err = ex.Message;
            }
            return(err);
        }
示例#31
0
        public override void handleGETRequest(HttpProcessor p)
        {
            try
            {
                string requestedPage = Uri.UnescapeDataString(p.request_url.AbsolutePath.TrimStart('/'));

                if (requestedPage == "admin")
                {
                    p.writeRedirect("admin/main");
                    return;
                }

                if (requestedPage == "login")
                {
                    LogOutUser(p, null);
                    return;
                }

                Session s = sm.GetSession(p.requestCookies.GetValue("cps"), p.requestCookies.GetValue("auth"), p.GetParam("rawauth"));
                if (s.sid != null && s.sid.Length == 16)
                {
                    p.responseCookies.Add("cps", s.sid, TimeSpan.FromMinutes(s.sessionLengthMinutes));
                }

                if (requestedPage == "logout")
                {
                    LogOutUser(p, s);
                    return;
                }


                if (requestedPage.StartsWith("admin/"))
                {
                    string adminPage = requestedPage == "admin" ? "" : requestedPage.Substring("admin/".Length);
                    if (string.IsNullOrWhiteSpace(adminPage))
                    {
                        adminPage = "main";
                    }
                    int idxQueryStringStart = adminPage.IndexOf('?');
                    if (idxQueryStringStart == -1)
                    {
                        idxQueryStringStart = adminPage.Length;
                    }
                    adminPage = adminPage.Substring(0, idxQueryStringStart);
                    Pages.Admin.AdminPage.HandleRequest(adminPage, p, s);
                    return;
                }
                else if (requestedPage.StartsWith("image/"))
                {
                    requestedPage = requestedPage.Substring("image/".Length);
                    #region image/
                    if (requestedPage.EndsWith(".jpg") || requestedPage.EndsWith(".jpeg") || requestedPage.EndsWith(".png") || requestedPage.EndsWith(".webp"))
                    {
                        int    extensionLength = requestedPage[requestedPage.Length - 4] == '.' ? 4 : 5;
                        string format          = requestedPage.Substring(requestedPage.Length - (extensionLength - 1));
                        string cameraId        = requestedPage.Substring(0, requestedPage.Length - extensionLength);
                        cameraId = cameraId.ToLower();

                        int minPermission = cm.GetCameraMinPermission(cameraId);
                        if (minPermission == 101)
                        {
                            p.writeFailure();
                            return;
                        }
                        if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission))
                        {
                            LogOutUser(p, s);
                            return;
                        }
                        int          wait        = p.GetIntParam("wait", 5000);
                        IPCameraBase cam         = cm.GetCamera(cameraId);
                        byte[]       latestImage = cm.GetLatestImage(cameraId, wait);
                        int          patience    = p.GetIntParam("patience");
                        if (patience > 0)
                        {
                            if (patience > 5000)
                            {
                                patience = 5000;
                            }

                            int timeLeft = patience;
                            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
                            timer.Start();
                            while (s.DuplicateImageSendCheck(cameraId, latestImage) && cam != null && timeLeft > 0)
                            {
                                // The latest image was already sent to the user in a previous image request.
                                // Wait for up to 5 seconds as desired by the user to get a "new" image.
                                cam.newFrameWaitHandle.WaitOne(Math.Max(50, timeLeft));                                  // This EventWaitHandle nonsense isn't perfect, so this should prevent excessively long delays in the event of a timing error.
                                latestImage = cm.GetLatestImage(cameraId);
                                timeLeft    = patience - (int)timer.ElapsedMilliseconds;
                            }
                        }
                        if (latestImage.Length == 0)
                        {
                            p.writeFailure("502 Bad Gateway");
                            return;
                        }
                        ImageFormat imgFormat = ImageFormat.Jpeg;
                        latestImage = ImageConverter.HandleRequestedConversionIfAny(latestImage, p, ref imgFormat, format);
                        p.tcpClient.SendBufferSize = latestImage.Length + 256;
                        p.writeSuccess(Util.GetMime(imgFormat), latestImage.Length);
                        p.outputStream.Flush();
                        p.rawOutputStream.Write(latestImage, 0, latestImage.Length);
                    }
                    else if (requestedPage.EndsWith(".mjpg"))
                    {
                        string cameraId = requestedPage.Substring(0, requestedPage.Length - 5);
                        cameraId = cameraId.ToLower();
                        int minPermission = cm.GetCameraMinPermission(cameraId);
                        if (minPermission == 101)
                        {
                            p.writeFailure();
                            return;
                        }
                        if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission))
                        {
                            LogOutUser(p, s);
                            return;
                        }
                        if (cm.GetLatestImage(cameraId).Length == 0)
                        {
                            return;
                        }
                        // Increasing the send buffer size here does not help streaming fluidity.
                        p.writeSuccess("multipart/x-mixed-replace;boundary=ipcamera");
                        byte[] newImage;
                        byte[] lastImage = null;
                        while (!this.stopRequested)
                        {
                            try
                            {
                                newImage = cm.GetLatestImage(cameraId);
                                while (newImage == lastImage)
                                {
                                    Thread.Sleep(1);
                                    newImage = cm.GetLatestImage(cameraId);
                                    if (this.stopRequested)
                                    {
                                        return;
                                    }
                                }
                                lastImage = newImage;

                                ImageFormat imgFormat = ImageFormat.Jpeg;
                                byte[]      sendImage = ImageConverter.HandleRequestedConversionIfAny(newImage, p, ref imgFormat);

                                p.outputStream.WriteLine("--ipcamera");
                                p.outputStream.WriteLine("Content-Type: " + Util.GetMime(imgFormat));
                                p.outputStream.WriteLine("Content-Length: " + sendImage.Length);
                                p.outputStream.WriteLine();
                                p.outputStream.Flush();
                                p.rawOutputStream.Write(sendImage, 0, sendImage.Length);
                                p.rawOutputStream.Flush();
                                p.outputStream.WriteLine();
                            }
                            catch (Exception ex)
                            {
                                if (!p.isOrdinaryDisconnectException(ex))
                                {
                                    Logger.Debug(ex);
                                }
                                break;
                            }
                        }
                    }
                    else if (requestedPage.EndsWith(".ogg"))
                    {
                        string cameraId = requestedPage.Substring(0, requestedPage.Length - 4);
                        cameraId = cameraId.ToLower();
                        int minPermission = cm.GetCameraMinPermission(cameraId);
                        if (minPermission == 101)
                        {
                            p.writeFailure();
                            return;
                        }
                        if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission))
                        {
                            LogOutUser(p, s);
                            return;
                        }
                        IPCameraBase _cam = cm.GetCamera(cameraId);
                        if (_cam is Html5VideoCamera)
                        {
                            Html5VideoCamera         cam            = (Html5VideoCamera)_cam;
                            ConcurrentQueue <byte[]> myDataListener = new ConcurrentQueue <byte[]>();
                            try
                            {
                                cam.RegisterStreamListener(myDataListener);
                                p.writeSuccess("application/octet-stream");
                                p.outputStream.Flush();
                                byte[] outputBuffer;
                                int    chunkCount = 0;
                                while (!this.stopRequested)
                                {
                                    try
                                    {
                                        chunkCount = myDataListener.Count;
                                        if (chunkCount > 100)
                                        {
                                            return;                                             // This connection is falling too far behind.  End it.
                                        }
                                        else if (chunkCount > 0)
                                        {
                                            Console.Write(chunkCount + " ");
                                            if (myDataListener.TryDequeue(out outputBuffer))
                                            {
                                                p.rawOutputStream.Write(outputBuffer, 0, outputBuffer.Length);
                                                p.rawOutputStream.Flush();
                                            }
                                        }
                                        else
                                        {
                                            Thread.Sleep(1);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        if (!p.isOrdinaryDisconnectException(ex))
                                        {
                                            Logger.Debug(ex);
                                        }
                                        break;
                                    }
                                }
                            }
                            finally
                            {
                                cam.UnregisterStreamListener(myDataListener);
                            }
                        }
                        else
                        {
                            p.writeFailure("501 Not Implemented");
                        }
                    }
                    else if (requestedPage.EndsWith(".cam"))
                    {
                        string cameraId = requestedPage.Substring(0, requestedPage.Length - 4);
                        cameraId = cameraId.ToLower();
                        int minPermission = cm.GetCameraMinPermission(cameraId);
                        if (minPermission == 101)
                        {
                            p.writeFailure();
                            return;
                        }
                        if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission))
                        {
                            LogOutUser(p, s);
                            return;
                        }
                        IPCameraBase cam = cm.GetCamera(cameraId);
                        if (cam != null && cam.cameraSpec.ptzType == MJpegCameraProxy.Configuration.PtzType.Dahua || cam.cameraSpec.ptzType == MJpegCameraProxy.Configuration.PtzType.Hikvision)
                        {
                            p.writeRedirect("../Camera.html?cam=" + cameraId);
                            return;
                        }

                        string userAgent = p.GetHeaderValue("User-Agent", "");
                        bool   isMobile  = userAgent.Contains("iPad") || userAgent.Contains("iPhone") || userAgent.Contains("Android") || userAgent.Contains("BlackBerry");

                        bool   isLanConnection = p == null ? false : p.IsLanConnection;
                        int    defaultRefresh  = isLanConnection && !isMobile ? -1 : 250;
                        string html            = CamPage.GetHtml(cameraId, !isMobile, p.GetIntParam("refresh", defaultRefresh), p.GetBoolParam("override") ? -1 : 600000, p);
                        if (string.IsNullOrEmpty(html) || html == "NO")
                        {
                            p.writeFailure();
                            return;
                        }
                        p.writeSuccess("text/html");
                        p.outputStream.Write(html);
                    }
                    else if (requestedPage == "PTZPRESETIMG")
                    {
                        string cameraId = p.GetParam("id");
                        cameraId = cameraId.ToLower();
                        IPCameraBase cam = cm.GetCamera(cameraId);
                        if (cam != null)
                        {
                            int index = p.GetIntParam("index", -1);
                            if (index > -1)
                            {
                                if (cam.cameraSpec.ptz_proxy)
                                {
                                    string auth = (!string.IsNullOrEmpty(cam.cameraSpec.ptz_username) && !string.IsNullOrEmpty(cam.cameraSpec.ptz_password)) ? "rawauth=" + HttpUtility.UrlEncode(cam.cameraSpec.ptz_username) + ":" + HttpUtility.UrlEncode(cam.cameraSpec.ptz_password) + "&" : "";
                                    byte[] data = SimpleProxy.GetData("http://" + cam.cameraSpec.ptz_hostName + "/PTZPRESETIMG?" + auth + "id=" + HttpUtility.UrlEncode(cam.cameraSpec.ptz_proxy_cameraId) + "&index=" + index);
                                    if (data.Length > 0)
                                    {
                                        p.writeSuccess("image/jpg", data.Length);
                                        p.outputStream.Flush();
                                        p.rawOutputStream.Write(data, 0, data.Length);
                                        return;
                                    }
                                }
                                else
                                {
                                    string fileName      = Globals.ThumbsDirectoryBase + cameraId + index + ".jpg";
                                    int    minPermission = cm.GetCameraMinPermission(cameraId);
                                    if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission) || minPermission == 101)
                                    {
                                    }
                                    else
                                    {
                                        if (File.Exists(fileName))
                                        {
                                            byte[] bytes = File.ReadAllBytes(fileName);
                                            p.writeSuccess("image/jpg", bytes.Length);
                                            p.outputStream.Flush();
                                            p.rawOutputStream.Write(bytes, 0, bytes.Length);
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                        {                         // Failed to get image thumbnail
                            byte[] bytes = File.ReadAllBytes(Globals.WWWPublicDirectoryBase + "Images/qmark.png");
                            p.writeSuccess("image/png", bytes.Length);
                            p.outputStream.Flush();
                            p.rawOutputStream.Write(bytes, 0, bytes.Length);
                            return;
                        }
                    }
                    else if (requestedPage.EndsWith(".wanscamstream"))
                    {
                        string       cameraId = requestedPage.Substring(0, requestedPage.Length - ".wanscamstream".Length);
                        IPCameraBase cam      = cm.GetCamera(cameraId);
                        if (cam == null)
                        {
                            return;
                        }
                        if (!cam.cameraSpec.wanscamCompatibilityMode)
                        {
                            return;
                        }
                        if (p.RemoteIPAddress != "127.0.0.1")
                        {
                            return;
                        }
                        Uri    url  = new Uri(cam.cameraSpec.imageryUrl);
                        string host = url.Host;
                        int    port = url.Port;
                        string path = url.PathAndQuery;
                        //string path = "/livestream.cgi?user=admin&pwd=nooilwell&streamid=0&audio=0&filename=";
                        //string path = "/videostream.cgi?user=admin&pwd=nooilwell&resolution=8";
                        int total = 0;
                        try
                        {
                            //Console.WriteLine("opening");
                            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                            socket.Connect(host, port);
                            byte[] buffer = new byte[4096];
                            socket.Send(UTF8Encoding.UTF8.GetBytes("GET " + path + " HTTP/1.1\r\nHost: " + host + ":" + port + "\r\nConnection: close\r\n\r\n"));
                            //Console.WriteLine("open");
                            int read = socket.Receive(buffer);
                            p.writeSuccess("video/raw");
                            p.outputStream.Flush();
                            while (read > 0 && socket.Connected && p.tcpClient.Connected)
                            {
                                p.rawOutputStream.Write(buffer, 0, read);
                                total += read;
                                //Console.WriteLine(read);
                                read = socket.Receive(buffer);
                            }
                            //Console.WriteLine("close");
                        }
                        catch (Exception ex)
                        {
                            if (!p.isOrdinaryDisconnectException(ex))
                            {
                                Logger.Debug(ex);
                            }
                        }
                    }
                    #endregion
                }
                else if (requestedPage.StartsWith("control/"))
                {
                    requestedPage = requestedPage.Substring("control/".Length);
                    #region control/
                    if (requestedPage == "keepalive")
                    {
                        string cameraId = p.GetParam("id");
                        cameraId = cameraId.ToLower();
                        int minPermission = cm.GetCameraMinPermission(cameraId);
                        if (minPermission == 101)
                        {
                            p.writeFailure();
                            return;
                        }
                        if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission))
                        {
                            p.writeFailure("403 Forbidden");
                            return;
                        }
                        cm.GetRTSPUrl(cameraId, p);
                        p.writeSuccess("text/plain");
                        p.outputStream.Write("1");
                    }

                    else if (requestedPage == "PTZ")
                    {
                        string cameraId = p.GetParam("id");
                        cameraId = cameraId.ToLower();
                        int minPermission = cm.GetCameraMinPermission(cameraId);
                        if (minPermission == 101)
                        {
                            p.writeFailure();
                            return;
                        }
                        if ((s == null && minPermission > 0) || (s != null && s.permission < minPermission))
                        {
                            LogOutUser(p, s);
                            return;
                        }
                        PTZ.RunCommand(cameraId, p.GetParam("cmd"));
                        p.writeSuccess("text/plain");
                    }
                    #endregion
                }
                else
                {
                    #region www
                    int permissionRequired;
                    if (!Util.TryGetValue(requestedPage.ToLower(), MJpegWrapper.cfg.GetWwwFilesList(), out permissionRequired))
                    {
                        permissionRequired = -1;
                    }


                    string wwwDirectory = permissionRequired == -1 ? Globals.WWWPublicDirectoryBase : Globals.WWWDirectoryBase;

                    if (permissionRequired < 0)
                    {
                        permissionRequired = 0;
                    }
                    else if (permissionRequired > 100)
                    {
                        permissionRequired = 100;
                    }

                    if (permissionRequired > s.permission)
                    {
                        LogOutUser(p, s);
                        return;
                    }

                    DirectoryInfo WWWDirectory     = new DirectoryInfo(wwwDirectory);
                    string        wwwDirectoryBase = WWWDirectory.FullName.Replace('\\', '/').TrimEnd('/') + '/';
                    FileInfo      fi             = new FileInfo(wwwDirectoryBase + requestedPage);
                    string        targetFilePath = fi.FullName.Replace('\\', '/');
                    if (!targetFilePath.StartsWith(wwwDirectoryBase) || targetFilePath.Contains("../"))
                    {
                        p.writeFailure("400 Bad Request");
                        return;
                    }
                    if (!fi.Exists)
                    {
                        p.writeFailure();
                        return;
                    }

                    // && (fi.Extension == ".html" || fi.Extension == ".htm")
                    if (fi.Name.ToLower() == "camera.html" && fi.Length < 256000)
                    {
                        p.writeSuccess(Mime.GetMimeType(fi.Extension));
                        string   html = File.ReadAllText(fi.FullName);
                        CamPage2 cp   = new CamPage2(html, p);
                        html = cp.Html;
                        html = html.Replace("%ALLCAMS%", string.Join(",", MJpegServer.cm.GenerateAllCameraIdList()));
                        html = html.Replace("%ALLCAMS_IDS_NAMES_JS_ARRAY%", MJpegServer.cm.GenerateAllCameraIdNameList(s == null ? 0 : s.permission));
                        try
                        {
                            html = html.Replace("%REMOTEIP%", p.RemoteIPAddress);
                        }
                        catch (Exception ex)
                        {
                            Logger.Debug(ex);
                        }
                        p.outputStream.Write(html);
                        p.outputStream.Flush();
                    }
                    else if ((fi.Extension == ".html" || fi.Extension == ".htm") && fi.Length < 256000)
                    {
                        p.writeSuccess(Mime.GetMimeType(fi.Extension));
                        string html = File.ReadAllText(fi.FullName);
                        html = html.Replace("%ALLCAMS%", string.Join(",", MJpegServer.cm.GenerateAllCameraIdList()));
                        html = html.Replace("%ALLCAMS_IDS_NAMES_JS_ARRAY%", MJpegServer.cm.GenerateAllCameraIdNameList(s == null ? 0 : s.permission));
                        try
                        {
                            html = html.Replace("%REMOTEIP%", p.RemoteIPAddress);
                        }
                        catch (Exception ex)
                        {
                            Logger.Debug(ex);
                        }
                        p.outputStream.Write(html);
                        p.outputStream.Flush();
                    }
                    else
                    {
                        List <KeyValuePair <string, string> > additionalHeaders = new List <KeyValuePair <string, string> >();
                        additionalHeaders.Add(new KeyValuePair <string, string>("Cache-Control", "max-age=3600, public"));
                        p.writeSuccess(Mime.GetMimeType(fi.Extension), additionalHeaders: additionalHeaders);
                        p.outputStream.Flush();
                        using (FileStream fs = fi.OpenRead())
                        {
                            fs.CopyTo(p.rawOutputStream);
                        }
                        p.rawOutputStream.Flush();
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                if (!p.isOrdinaryDisconnectException(ex))
                {
                    Logger.Debug(ex);
                }
            }
        }
示例#32
0
        public override void handleGETRequest(HttpProcessor p)
        {
            string pageLower = p.requestedPage.ToLower();

            if (pageLower.StartsWith("api/"))
            {
                p.writeFailure("405 Method Not Allowed");
            }
            else if (p.requestedPage == "")
            {
                p.writeRedirect("default.html");
            }
            else if (p.requestedPage == "TEST")
            {
                StringBuilder sb = new StringBuilder();
                p.writeSuccess("text/plain");
                p.outputStream.Write(string.Join(", ", Process.GetProcessesByName("svchost").Select(i => ProcessHelper.GetUserWhichOwnsProcess(i.Id))));
            }
            else
            {
                string wwwPath = Globals.ApplicationDirectoryBase + "www/";
#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    wwwPath = Globals.ApplicationDirectoryBase + "../../www/";
                }
#endif
                DirectoryInfo WWWDirectory     = new DirectoryInfo(wwwPath);
                string        wwwDirectoryBase = WWWDirectory.FullName.Replace('\\', '/').TrimEnd('/') + '/';
                FileInfo      fi             = new FileInfo(wwwDirectoryBase + p.requestedPage);
                string        targetFilePath = fi.FullName.Replace('\\', '/');
                if (!targetFilePath.StartsWith(wwwDirectoryBase) || targetFilePath.Contains("../"))
                {
                    p.writeFailure("400 Bad Request");
                    return;
                }
                if (!fi.Exists)
                {
                    return;
                }
                if ((fi.Extension == ".html" || fi.Extension == ".htm") && fi.Length < 256000)
                {
                    string html = File.ReadAllText(fi.FullName);
                    html = html.Replace("%%VERSION%%", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    html = html.Replace("%%RND%%", rnd.ToString());

                    byte[] data = Encoding.UTF8.GetBytes(html);
                    if (!p.GetBoolParam("nocompress"))
                    {
                        p.CompressResponseIfCompatible();
                    }
                    p.writeSuccess(Mime.GetMimeType(fi.Extension));
                    p.outputStream.Flush();
                    p.tcpStream.Write(data, 0, data.Length);
                    p.tcpStream.Flush();
                }
                else
                {
                    string mime = Mime.GetMimeType(fi.Extension);
                    if (pageLower.StartsWith(".well-known/acme-challenge/"))
                    {
                        mime = "text/plain";
                    }
                    if (fi.LastWriteTimeUtc.ToString("R") == p.GetHeaderValue("if-modified-since"))
                    {
                        p.writeSuccess(mime, -1, "304 Not Modified");
                        return;
                    }
                    if (!p.GetBoolParam("nocompress"))
                    {
                        p.CompressResponseIfCompatible();
                    }
                    p.writeSuccess(mime, additionalHeaders: GetCacheLastModifiedHeaders(TimeSpan.FromHours(1), fi.LastWriteTimeUtc));
                    p.outputStream.Flush();
                    using (FileStream fs = fi.OpenRead())
                    {
                        fs.CopyTo(p.tcpStream);
                    }
                    p.tcpStream.Flush();
                }
            }
        }
示例#33
0
 public override string GetBody(Mime mime)
 {
     return(string.Format(MailTemplate.Body, mime.MainEntity.Subject, SuppliersEmails));
 }
示例#34
0
        public override void handleGETRequest(HttpProcessor p)
        {
            string pageLower = p.requestedPage.ToLower();

            //if (pageLower == "manualfix")
            //{
            //	if (IsAdmin(p))
            //	{
            //		p.writeSuccess("text/plain");
            //		try
            //		{
            //			Agent.RetroactiveFixData();
            //		}
            //		catch (Exception ex)
            //		{
            //			p.outputStream.WriteLine(ex.ToString());
            //		}
            //	}
            //	else
            //		p.writeFailure("403 Forbidden");
            //}
            if (pageLower.StartsWith("api/"))
            {
                p.writeFailure("405 Method Not Allowed");
            }
            else if (p.requestedPage == "IP")
            {
                p.writeSuccess("text/plain");
                p.outputStream.Write(p.RemoteIPAddressStr);
            }
            else if (p.requestedPage == "HEADERS")
            {
                p.writeSuccess("text/plain");
                p.outputStream.Write(string.Join(Environment.NewLine, p.httpHeadersRaw.Select(h => h.Key + ": " + h.Value)));
            }
            else if (p.requestedPage == "IP")
            {
                p.writeSuccess("text/plain");
                p.outputStream.Write(p.RemoteIPAddressStr);
            }
            else if (p.requestedPage == "")
            {
                p.writeRedirect("default.html");
            }
            else
            {
                string wwwPath = Globals.ApplicationDirectoryBase + "www/";
#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    wwwPath = Globals.ApplicationDirectoryBase + "../../../www/";
                }
#endif
                DirectoryInfo WWWDirectory     = new DirectoryInfo(wwwPath);
                string        wwwDirectoryBase = WWWDirectory.FullName.Replace('\\', '/').TrimEnd('/') + '/';
                FileInfo      fi             = new FileInfo(wwwDirectoryBase + p.requestedPage);
                string        targetFilePath = fi.FullName.Replace('\\', '/');
                if (!targetFilePath.StartsWith(wwwDirectoryBase) || targetFilePath.Contains("../"))
                {
                    p.writeFailure("400 Bad Request");
                    return;
                }
                if (!fi.Exists)
                {
                    return;
                }
                if ((fi.Extension == ".html" || fi.Extension == ".htm") && fi.Length < 256000)
                {
                    string html = File.ReadAllText(fi.FullName);
                    html = html.Replace("%%VERSION%%", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    html = html.Replace("%%RND%%", rnd.ToString());
                    html = html.Replace("%%ADMIN%%", IsAdmin(p) ? "true" : "false");

                    byte[] data = Encoding.UTF8.GetBytes(html);
                    p.writeSuccess(Mime.GetMimeType(fi.Extension), data.Length);
                    p.outputStream.Flush();
                    p.tcpStream.Write(data, 0, data.Length);
                    p.tcpStream.Flush();
                }
                else
                {
                    string mime = Mime.GetMimeType(fi.Extension);
                    if (pageLower.StartsWith(".well-known/acme-challenge/"))
                    {
                        mime = "text/plain";
                    }
                    if (fi.LastWriteTimeUtc.ToString("R") == p.GetHeaderValue("if-modified-since"))
                    {
                        p.writeSuccess(mime, -1, "304 Not Modified");
                        return;
                    }
                    p.writeSuccess(mime, fi.Length, additionalHeaders: GetCacheLastModifiedHeaders(TimeSpan.FromHours(1), fi.LastWriteTimeUtc));
                    p.outputStream.Flush();
                    using (FileStream fs = fi.OpenRead())
                    {
                        fs.CopyTo(p.tcpStream);
                    }
                    p.tcpStream.Flush();
                }
            }
        }
示例#35
0
 public override string GetBody(Mime mime)
 {
     return(string.Format(MailTemplate.Body, mime.MainEntity.Subject, mime.MailSize() / 1024.0 / 1024.0, Settings.Default.MaxMiniMailSize));
 }
示例#36
0
        private IActionResult GetFile(FileInfo file, string dataStream = null)
        {
            if (file == null)
            {
                return(NotFound());
            }

            if (dataStream != null && file.Exists && file.AlternateDataStreamExists(dataStream))
            {
                return(File(file.GetAlternateDataStream(dataStream, FileMode.Open).OpenRead(), Mime.GetType(dataStream)));
            }

            if (dataStream == null && file.Exists)
            {
                return(PhysicalFile(file.FullName, Mime.GetType(file.Name)));
            }

            return(NotFound());
        }
示例#37
0
        public void CanGetMime(FormatId format, string mediaType)
        {
            var mime = Mime.FromFormat(format);

            Assert.Equal(mediaType, mime.Name);
        }
示例#38
0
        public string Should_Get_Mime_Type_From_Extension_Ignoring_Case(string extension)
        {
            string result = Mime.GetByFileExtension(extension);

            return(result);
        }
示例#39
0
 /// <summary>
 /// Creates an attachment object from a <see cref="Mime.MessagePart"/>
 /// </summary>
 /// <param name="attachment"></param>
 internal Attachment(Mime.MessagePart attachment)
 {
     ContentId = attachment.ContentId;
     IsInline = ContentId != null;
     IsContactPhoto = false;
     RenderingPosition = -1;
     _data = attachment.Body;
     FileName = FileManager.RemoveInvalidFileNameChars(attachment.FileName);
     StorageName = null;
 }
示例#40
0
        static void pop3()
        {
            List <string> gotemailids = new List <string>();

            using (LumiSoft.Net.POP3.Client.POP3_Client pop3 = new POP3_Client())
            {
                try
                {
                    //与pop3服务器建立连接
                    pop3.Connect("pop.qq.com", 110, false);
                    //验证身份
                    pop3.Login("*****@*****.**", "myhaiyan");

                    //获取邮件信息列表
                    POP3_ClientMessageCollection infos = pop3.Messages;
                    foreach (POP3_ClientMessage info in infos)
                    {
                        //每封email会有一个在pop3服务器范围内唯一的id,检查这个id是否存在就可以知道以前有没有接收过这封邮件
                        if (gotemailids.Contains(info.UID))
                        {
                            continue;
                        }
                        //获取这封邮件的内容
                        byte[] bytes = info.MessageToByte();
                        //记录这封邮件的id
                        gotemailids.Add(info.UID);

                        //解析从pop3服务器发送过来的邮件信息
                        Mime m = Mime.Parse(bytes);
                        if (m != null)
                        {
                            string mailfrom     = "";
                            string mailfromname = "";
                            if (m.MainEntity.From != null)
                            {
                                for (int i = 0; i < m.MainEntity.From.Mailboxes.Length; i++)
                                {
                                    if (i == 0)
                                    {
                                        mailfrom = (m.MainEntity.From).Mailboxes[i].EmailAddress;
                                    }
                                    else
                                    {
                                        mailfrom += string.Format(",{0}", (m.MainEntity.From).Mailboxes[i].EmailAddress);
                                    }
                                    mailfromname = (m.MainEntity.From).Mailboxes[0].DisplayName != ""
                                                       ? (m.MainEntity.From).Mailboxes[0].DisplayName
                                                       : (m.MainEntity.From).Mailboxes[0].LocalPart;
                                }
                            }
                            string mailto             = "";
                            string mailtotocollection = "";
                            if (m.MainEntity.To != null)
                            {
                                mailtotocollection = m.MainEntity.To.ToAddressListString();

                                for (int i = 0; i < m.MainEntity.To.Mailboxes.Length; i++)
                                {
                                    if (i == 0)
                                    {
                                        mailto = (m.MainEntity.To).Mailboxes[i].EmailAddress;
                                    }
                                    else
                                    {
                                        mailto += string.Format(",{0}", (m.MainEntity.To).Mailboxes[i].EmailAddress);
                                    }
                                }
                            }
                        }
                        //获取附件
                        foreach (MimeEntity entry in m.Attachments)
                        {
                            string filename = entry.ContentDisposition_FileName; //获取文件名称
                            string path     = AppDomain.CurrentDomain.BaseDirectory + @"attch\" + filename;
                            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"attch"))
                            {
                                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"attch");
                            }
                            if (File.Exists(path))
                            {
                                Random random  = new Random();
                                int    newfile = random.Next(1, 100000);
                                path = AppDomain.CurrentDomain.BaseDirectory + @"attch\" + newfile.ToString();
                                Directory.CreateDirectory(path);
                                path += @"\" + filename;
                            }
                            byte[]     data        = entry.Data;
                            FileStream pfilestream = null;
                            pfilestream = new FileStream(path, FileMode.Create);
                            pfilestream.Write(data, 0, data.Length);
                            pfilestream.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
 private void GenerateMimeId(Mime mime)
 {
     mime.Id = HashUtil.Crc32(mime.ContentType);
 }
示例#42
0
        public override void handleGETRequest(HttpProcessor p)
        {
            BasicEventTimer bet = new BasicEventTimer();

            bet.Start("GET " + p.requestedPage);
            try
            {
                p.tcpClient.NoDelay = true;
                string pageLower = p.requestedPage.ToLower();
                if (pageLower == "json")
                {
                    p.writeFailure("405 Method Not Allowed", "json API requests must use the POST method");
                }
                else if (p.requestedPage.StartsWith("WebSocketClientProxy/"))
                {
                    WebSocketProxy.HandleWebSocketClientProxyRequest(p);
                }
                else if (p.requestedPage.StartsWith("WebSocketHostProxy/"))
                {
                    WebSocketProxy.HandleWebSocketHostProxyResponse(p);
                }
                //else if (p.requestedPage == "windowskeycodes")
                //{
                //	p.writeSuccess();
                //	p.outputStream.Write("<table><thead><tr><th>KeyCode</th><th>Name</th></tr></thead><tbody>");
                //	HashSet<int> addedKeyCodes = new HashSet<int>();
                //	foreach (int keyCode in ((IEnumerable<int>)Enum.GetValues(typeof(System.Windows.Forms.Keys))))
                //	{
                //		p.outputStream.Write("<tr><td>" + keyCode + "</td><td>" + (System.Windows.Forms.Keys)keyCode + "</td></tr>");
                //	}
                //	p.outputStream.Write("</tbody></table>");
                //}
                else
                {
                    #region www
                    DirectoryInfo WWWDirectory     = new DirectoryInfo(ServiceWrapper.settings.GetWWWDirectoryBase());
                    string        wwwDirectoryBase = WWWDirectory.FullName.Replace('\\', '/').TrimEnd('/') + '/';

                    FileInfo fi = null;
                    if (p.requestedPage == "")
                    {
                        fi = GetDefaultFile(wwwDirectoryBase);
                    }
                    else
                    {
                        try
                        {
                            fi = new FileInfo(wwwDirectoryBase + p.requestedPage);
                        }
                        catch
                        {
                            fi = GetDefaultFile(wwwDirectoryBase);
                        }
                    }
                    string targetFilePath = fi.FullName.Replace('\\', '/');
                    if (!targetFilePath.StartsWith(wwwDirectoryBase) || targetFilePath.Contains("../"))
                    {
                        p.writeFailure("400 Bad Request");
                        return;
                    }
                    if (webpackProxy != null)
                    {
                        // Handle hot module reload provided by webpack dev server.
                        switch (fi.Extension.ToLower())
                        {
                        case ".js":
                        case ".map":
                        case ".css":
                        case ".json":
                            bet.Start("Proxy Start");
                            webpackProxy.Proxy(p);
                            bet.Start("Proxy End");
                            return;
                        }
                    }
                    if (!fi.Exists)
                    {
                        fi = GetDefaultFile(wwwDirectoryBase);
                        if (!fi.Exists)
                        {
                            p.writeFailure();
                            return;
                        }
                    }

                    if ((fi.Extension == ".html" || fi.Extension == ".htm") && fi.Length < 256000)
                    {
                        bet.Start("Write HTML");
                        string html = File.ReadAllText(fi.FullName);
                        try
                        {
                            //html = html.Replace("%%REMOTEIP%%", p.RemoteIPAddressStr);
                            html = html.Replace("%%SYSTEM_NAME%%", "SHRD");
                            html = html.Replace("%%APP_VERSION%%", AppVersion.VersionNumber);
                            html = html.Replace("%%APPPATH%%", "/");
                        }
                        catch (Exception ex)
                        {
                            Logger.Debug(ex);
                        }
                        p.writeSuccess(Mime.GetMimeType(fi.Extension));
                        p.outputStream.Write(html);
                        p.outputStream.Flush();
                    }
                    else
                    {
                        bet.Start("Write Response");
                        if (fi.LastWriteTimeUtc.ToString("R") == p.GetHeaderValue("if-modified-since"))
                        {
                            p.writeSuccess(Mime.GetMimeType(fi.Extension), -1, "304 Not Modified");
                            return;
                        }
                        using (FileStream fs = fi.OpenRead())
                        {
                            p.writeSuccess(Mime.GetMimeType(fi.Extension), fi.Length, additionalHeaders: GetCacheLastModifiedHeaders(TimeSpan.FromHours(1), fi.LastWriteTimeUtc));
                            p.outputStream.Flush();
                            fs.CopyTo(p.tcpStream);
                            p.tcpStream.Flush();
                        }
                    }
                    #endregion
                }
            }
            finally
            {
                bet.Stop();
                //Logger.Info(bet.ToString("\r\n"));
            }
        }
示例#43
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static System.Web.Mvc.ContentResult SendByApi(Context context, string reference, long id)
        {
            if (!Mime.ValidateOnApi(contentType: context.ContentType))
            {
                return(ApiResults.BadRequest(context: context));
            }
            var itemModel = new ItemModel(
                context: context,
                referenceId: id);
            var siteModel = new SiteModel(
                context: context,
                siteId: itemModel.SiteId);
            var ss = SiteSettingsUtilities.Get(
                context: context,
                siteModel: siteModel,
                referenceId: itemModel.ReferenceId);
            var outgoingMailModel = new OutgoingMailModel(
                context: context,
                reference: reference,
                referenceId: id);
            var data = context.RequestDataString.Deserialize <OutgoingMailApiModel>();

            if (data == null)
            {
                return(ApiResults.Get(ApiResponses.BadRequest(context: context)));
            }
            if (!siteModel.WithinApiLimits(context: context))
            {
                return(ApiResults.Get(ApiResponses.OverLimitApi(
                                          context: context,
                                          siteId: itemModel.SiteId,
                                          limitPerSite: context.ContractSettings.ApiLimit())));
            }
            if (data.From != null)
            {
                outgoingMailModel.From = new System.Net.Mail.MailAddress(data.From);
            }
            if (data.To != null)
            {
                outgoingMailModel.To = data.To;
            }
            if (data.Cc != null)
            {
                outgoingMailModel.Cc = data.Cc;
            }
            if (data.Bcc != null)
            {
                outgoingMailModel.Bcc = data.Bcc;
            }
            if (data.Title != null)
            {
                outgoingMailModel.Title = new Title(data.Title);
            }
            if (data.Body != null)
            {
                outgoingMailModel.Body = data.Body;
            }
            var invalid = OutgoingMailValidators.OnSending(
                context: context,
                ss: ss,
                outgoingMailModel: outgoingMailModel);

            switch (invalid.Type)
            {
            case Error.Types.None: break;

            default:
                return(ApiResults.Error(
                           context: context,
                           errorData: invalid));
            }
            var errorData = outgoingMailModel.Send(
                context: context,
                ss: ss,
                attachments: data.Attachments);

            switch (errorData.Type)
            {
            case Error.Types.None:
                return(ApiResults.Success(
                           id: id,
                           limitPerDate: context.ContractSettings.ApiLimit(),
                           limitRemaining: context.ContractSettings.ApiLimit() - ss.ApiCount,
                           message: Displays.MailTransmissionCompletion(
                               context: context,
                               data: outgoingMailModel.Title.DisplayValue)));

            default:
                return(ApiResults.Error(
                           context: context,
                           errorData: errorData));
            }
        }
        /// <summary>
        /// Gets if specified message matches with this class search-key.
        /// </summary>
        /// <param name="no">IMAP message sequence number.</param>
        /// <param name="uid">IMAP message UID.</param>
        /// <param name="size">IMAP message size in bytes.</param>
        /// <param name="internalDate">IMAP message INTERNALDATE (dateTime when server stored message).</param>
        /// <param name="flags">IMAP message flags.</param>
        /// <param name="mime">Mime message main header only.</param>
        /// <param name="bodyText">Message body text.</param>
        /// <returns></returns>
        public bool Match(long no,
                          long uid,
                          long size,
                          DateTime internalDate,
                          IMAP_MessageFlags flags,
                          Mime mime,
                          string bodyText)
        {
            #region ALL

            // ALL
            //		All messages in the mailbox; the default initial key for ANDing.
            if (m_SearchKeyName == "ALL")
            {
                return(true);
            }

            #endregion

            #region BEFORE

            // BEFORE <date>
            //	Messages whose internal date (disregarding time and timezone)
            //	is earlier than the specified date.
            else if (m_SearchKeyName == "BEFORE")
            {
                if (internalDate.Date < (DateTime)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region BODY

            // BODY <string>
            //	Messages that contain the specified string in the body of the message.
            //
            //	NOTE: Compare must be done on decoded header and decoded body of message.
            //		  In all search keys that use strings, a message matches the key if
            //		  the string is a substring of the field.  The matching is case-insensitive.
            else if (m_SearchKeyName == "BODY")
            {
                string val = bodyText;
                if (val != null && val.ToLower().IndexOf(((string)m_SearchKeyValue).ToLower()) > -1)
                {
                    return(true);
                }
            }

            #endregion

            #region HEADER

            // HEADER <field-name> <string>
            //	Messages that have a header with the specified field-name (as
            //	defined in [RFC-2822]) and that contains the specified string
            //	in the text of the header (what comes after the colon).  If the
            //	string to search is zero-length, this matches all messages that
            //	have a header line with the specified field-name regardless of
            //	the contents.
            //
            //	NOTE: Compare must be done on decoded header field value.
            //		  In all search keys that use strings, a message matches the key if
            //		  the string is a substring of the field.  The matching is case-insensitive.
            else if (m_SearchKeyName == "HEADER")
            {
                string[] headerField_value = (string[])m_SearchKeyValue;

                // If header field name won't end with :, add it
                if (!headerField_value[0].EndsWith(":"))
                {
                    headerField_value[0] = headerField_value[0] + ":";
                }

                if (mime.MainEntity.Header.Contains(headerField_value[0]))
                {
                    if (headerField_value[1].Length == 0)
                    {
                        return(true);
                    }
                    else if (
                        mime.MainEntity.Header.GetFirst(headerField_value[0]).Value.ToLower().IndexOf(
                            headerField_value[1].ToLower()) > -1)
                    {
                        return(true);
                    }
                }
            }

            #endregion

            #region KEYWORD

            // KEYWORD <flag>
            //	Messages with the specified keyword flag set.
            else if (m_SearchKeyName == "KEYWORD")
            {
                if ((flags & IMAP_Utils.ParseMessageFlags((string)m_SearchKeyValue)) != 0)
                {
                    return(true);
                }
            }

            #endregion

            #region LARGER

            // LARGER <n>
            //	Messages with an [RFC-2822] size larger than the specified number of octets.
            else if (m_SearchKeyName == "LARGER")
            {
                if (size > (long)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region NOT

            //	NOT <search-key> or (<search-key> <search-key> ...)(SearchGroup)
            //		Messages that do not match the specified search key.
            else if (m_SearchKeyName == "NOT")
            {
                return
                    (!SearchGroup.Match_Key_Value(m_SearchKeyValue,
                                                  no,
                                                  uid,
                                                  size,
                                                  internalDate,
                                                  flags,
                                                  mime,
                                                  bodyText));
            }

            #endregion

            #region ON

            // ON <date>
            //	Messages whose internal date (disregarding time and timezone)
            //	is within the specified date.
            else if (m_SearchKeyName == "ON")
            {
                if (internalDate.Date == (DateTime)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region OR

            //	OR <search-key1> <search-key2> - SearckKey can be parenthesis list of keys !
            //		Messages that match either search key.
            else if (m_SearchKeyName == "OR")
            {
                object serachKey1 = ((object[])m_SearchKeyValue)[0];
                object serachKey2 = ((object[])m_SearchKeyValue)[1];

                if (
                    SearchGroup.Match_Key_Value(serachKey1, no, uid, size, internalDate, flags, mime, bodyText) ||
                    SearchGroup.Match_Key_Value(serachKey2, no, uid, size, internalDate, flags, mime, bodyText))
                {
                    return(true);
                }
            }

            #endregion

            #region SENTBEFORE

            // SENTBEFORE <date>
            //	Messages whose [RFC-2822] Date: header (disregarding time and
            //	timezone) is earlier than the specified date.
            else if (m_SearchKeyName == "SENTBEFORE")
            {
                if (mime.MainEntity.Date.Date < (DateTime)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region SENTON

            // SENTON <date>
            //	Messages whose [RFC-2822] Date: header (disregarding time and
            //	timezone) is within the specified date.
            else if (m_SearchKeyName == "SENTON")
            {
                if (mime.MainEntity.Date.Date == (DateTime)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region SENTSINCE

            // SENTSINCE <date>
            //	Messages whose [RFC-2822] Date: header (disregarding time and
            //	timezone) is within or later than the specified date.
            else if (m_SearchKeyName == "SENTSINCE")
            {
                if (mime.MainEntity.Date.Date >= (DateTime)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region SINCE

            // SINCE <date>
            //	Messages whose internal date (disregarding time and timezone)
            //	is within or later than the specified date.
            else if (m_SearchKeyName == "SINCE")
            {
                if (internalDate.Date >= (DateTime)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region SMALLER

            // SMALLER <n>
            //	Messages with an [RFC-2822] size smaller than the specified	number of octets.
            else if (m_SearchKeyName == "SMALLER")
            {
                if (size < (long)m_SearchKeyValue)
                {
                    return(true);
                }
            }

            #endregion

            #region TEXT

            // TEXT <string>
            //	Messages that contain the specified string in the header or	body of the message.
            //
            //  NOTE: Compare must be done on decoded header and decoded body of message.
            //		  In all search keys that use strings, a message matches the key if
            //		  the string is a substring of the field.  The matching is case-insensitive.
            else if (m_SearchKeyName == "TEXT")
            {
                // See body first
                string val = bodyText;
                if (val != null && val.ToLower().IndexOf(((string)m_SearchKeyValue).ToLower()) > -1)
                {
                    return(true);
                }

                // If we reach so far, that means body won't contain specified text and we need to check header.
                foreach (HeaderField headerField in mime.MainEntity.Header)
                {
                    if (headerField.Value.ToLower().IndexOf(((string)m_SearchKeyValue).ToLower()) > -1)
                    {
                        return(true);
                    }
                }
            }

            #endregion

            #region UID

            // UID <sequence set>
            //	Messages with unique identifiers corresponding to the specified
            //	unique identifier set.  Sequence set ranges are permitted.
            else if (m_SearchKeyName == "UID")
            {
                return(((IMAP_SequenceSet)m_SearchKeyValue).Contains(uid));
            }

            #endregion

            #region UNKEYWORD

            // UNKEYWORD <flag>
            //	Messages that do not have the specified keyword flag set.
            else if (m_SearchKeyName == "UNKEYWORD")
            {
                if ((flags & IMAP_Utils.ParseMessageFlags((string)m_SearchKeyValue)) == 0)
                {
                    return(true);
                }
            }

            #endregion

            #region SEQUENCESET

            // <sequence set>
            //		Messages with message sequence numbers corresponding to the
            //		specified message sequence number set.
            else if (m_SearchKeyName == "SEQUENCESET")
            {
                return(((IMAP_SequenceSet)m_SearchKeyValue).Contains(no));
            }

            #endregion

            return(false);
        }
示例#45
0
 public void BasicUrls()
 {
     Assert.AreEqual(Mime.MimeTypes["jpg"], Mime.DetectImageMime("xyz/abc/def.jpg"));
 }
示例#46
0
        /// <summary>
        /// Gets specified mime entity. Returns null if specified mime entity doesn't exist.
        /// </summary>
        /// <param name="parser">Reference to mime parser.</param>
        /// <param name="mimeEntitySpecifier">Mime entity specifier. Nested mime entities are pointed by '.'. 
        /// For example: 1,1.1,2.1, ... .</param>
        /// <returns></returns>
        public static MimeEntity GetMimeEntity(Mime parser, string mimeEntitySpecifier)
        {
            // TODO: nested rfc 822 message

            // For single part message there is only one entity with value 1.
            // Example:
            //		header
            //		entity -> 1

            // For multipart message, entity counting starts from MainEntity.ChildEntities
            // Example:
            //		header
            //		multipart/mixed
            //			entity1  -> 1
            //			entity2  -> 2
            //          ...

            // Single part
            if ((parser.MainEntity.ContentType & MediaType_enum.Multipart) == 0)
            {
                if (mimeEntitySpecifier.Length == 1 && Convert.ToInt32(mimeEntitySpecifier) == 1)
                {
                    return parser.MainEntity;
                }
                else
                {
                    return null;
                }
            }
                // multipart
            else
            {
                MimeEntity entity = parser.MainEntity;
                string[] parts = mimeEntitySpecifier.Split('.');
                foreach (string part in parts)
                {
                    int mEntryNo = Convert.ToInt32(part) - 1;
                        // Enitites are zero base, mimeEntitySpecifier is 1 based.
                    if (mEntryNo > -1 && mEntryNo < entity.ChildEntities.Count)
                    {
                        entity = entity.ChildEntities[mEntryNo];
                    }
                    else
                    {
                        return null;
                    }
                }

                return entity;
            }
        }
示例#47
0
 public void UrlsWithHash()
 {
     Assert.AreEqual(Mime.MimeTypes["jpg"], Mime.DetectImageMime("xyz/abc/def.jpg#w=200"));
 }
示例#48
0
 /// <summary>
 /// Gets requested mime entity header. Returns null if specified mime entity doesn't exist.
 /// Note: Header terminator blank line is included.
 /// </summary>
 /// <param name="parser">Reference to mime parser.</param>
 /// <param name="mimeEntitySpecifier">Mime entity specifier. Nested mime entities are pointed by '.'. 
 /// For example: 1,1.1,2.1, ... .</param>
 /// <returns>Returns requested mime entity data or NULL if requested entry doesn't exist.</returns>
 public static byte[] GetMimeEntityHeader(Mime parser, string mimeEntitySpecifier)
 {
     MimeEntity mEntry = GetMimeEntity(parser, mimeEntitySpecifier);
     if (mEntry != null)
     {
         return GetMimeEntityHeader(mEntry);
     }
     else
     {
         return null;
     }
 }
        public void html_extension_should_have_correct_mime_type()
        {
            var result = Mime.Lookup("test.html");

            result.Should().Be("text/html");
        }
示例#50
0
 /// <summary>
 /// Gets requested mime entity data. Returns null if specified mime entity doesn't exist.
 /// </summary>
 /// <param name="parser">Reference to mime parser.</param>
 /// <param name="mimeEntitySpecifier">Mime entity specifier. Nested mime entities are pointed by '.'. 
 /// For example: 1,1.1,2.1, ... .</param>
 /// <returns>Returns requested mime entity data or NULL if requested entry doesn't exist.</returns>
 public static byte[] GetMimeEntityData(Mime parser, string mimeEntitySpecifier)
 {
     MimeEntity entity = GetMimeEntity(parser, mimeEntitySpecifier);
     if (entity != null)
     {
         return entity.DataEncoded;
     }
     else
     {
         return null;
     }
 }
示例#51
0
 public override string GetMimeTypeFromPath(string path)
 {
     if (_mime == null)
     {
         _mime = new Mime();
     }
     return _mime.Lookup(path);
 }
示例#52
0
 public void FontTests()
 {
     Assert.Equal("font/woff", Mime.FromFormat("woff").Name);
     Assert.Equal("font/woff2", Mime.FromFormat("woff2").Name);
 }
示例#53
0
 /// <summary>
 /// Sends specified message to specified smart host.
 /// </summary>
 /// <param name="smartHost">Smarthost name or IP.</param>
 /// <param name="port">SMTP port number. Normally this is 25.</param>
 /// <param name="hostName">Host name reported to SMTP server.</param>
 /// <param name="userName">SMTP user name. Note: Pass empty string if no authentication wanted.</param>
 /// <param name="password">SMTP password.</param>
 /// <param name="message">Mime message to send.</param>
 public static void QuickSendSmartHost(string smartHost,
                                       int port,
                                       string hostName,
                                       string userName,
                                       string password,
                                       Mime message)
 {
     QuickSendSmartHost(smartHost, port, false, hostName, userName, password, message);
 }
示例#54
0
 public static IEnumerable <MimeEntity> GetValidAttachements(this Mime mime)
 {
     return(mime.Attachments.Where(m => !String.IsNullOrEmpty(GetFilename(m)) && m.Data != null));
 }
示例#55
0
 /// <summary>
 /// Constructs FETCH BODY and BODYSTRUCTURE response.
 /// </summary>
 /// <param name="mime">Mime message.</param>
 /// <param name="bodystructure">Specifies if to construct BODY or BODYSTRUCTURE.</param>
 /// <returns></returns>
 public static string ConstructBodyStructure(Mime mime, bool bodystructure)
 {
     if (bodystructure)
     {
         return "BODYSTRUCTURE " + ConstructParts(mime.MainEntity, bodystructure);
     }
     else
     {
         return "BODY " + ConstructParts(mime.MainEntity, bodystructure);
     }
 }
        private void SendErrorToProvider(DocSourceHandlerForTesting handler, MiniMailException exception, Mime sourceLetter)
        {
            try {
                var memoryAppender = new MemoryAppender();
                memoryAppender.AddFilter(new LoggerMatchFilter {
                    AcceptOnMatch = true, LoggerToMatch = "PriceProcessor", Next = new DenyAllFilter()
                });
                BasicConfigurator.Configure(memoryAppender);

                handler.SendErrorLetterToSupplier(exception, sourceLetter);

                var events = memoryAppender.GetEvents();
                Assert.That(
                    events.Length,
                    Is.EqualTo(0),
                    "Ошибки при обработки задач сертификатов:\r\n{0}",
                    events.Select(item => {
                    if (string.IsNullOrEmpty(item.GetExceptionString()))
                    {
                        return(item.RenderedMessage);
                    }
                    else
                    {
                        return(item.RenderedMessage + Environment.NewLine + item.GetExceptionString());
                    }
                }).Implode("\r\n"));
            }
            finally {
                LogManager.ResetConfiguration();
            }
        }
示例#57
0
 private void GuiThongBaoLuong(string subject, string fileName, long idNguoiNhan)
 {
     Mime message = new Mime();
     MimeEntity texts_enity = null;
     MimeEntity attachments_entity = null;
     message.MainEntity.ContentType = MediaType_enum.Multipart_mixed;
     texts_enity = message.MainEntity.ChildEntities.Add();
     texts_enity.ContentType = MediaType_enum.Multipart_alternative;
     attachments_entity = message.MainEntity;
     //File đính kèm
     MimeEntity attachment_entity = attachments_entity.ChildEntities.Add();
     attachment_entity.ContentType = MediaType_enum.Application_octet_stream;
     attachment_entity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
     attachment_entity.ContentDisposition = ContentDisposition_enum.Attachment;
     attachment_entity.ContentDisposition_FileName = Path.GetFileName(fileName);
     attachment_entity.Data = File.ReadAllBytes(fileName);
     //Thông tin mail
     AddressList to = new AddressList();
     to.Add(new MailboxAddress("PL-Office", "*****@*****.**"));
     message.MainEntity.From = to;
     message.MainEntity.To = HelpZPLOEmail.GetAddressList(new long[] { idNguoiNhan });
     message.MainEntity.Subject = subject;
     message.MainEntity.Bcc = to;
     //Nội dung
     MimeEntity text_entity = texts_enity.ChildEntities.Add();
     text_entity.ContentType = MediaType_enum.Text_plain;
     text_entity.ContentType_CharSet = "utf-8";
     text_entity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
     text_entity.DataText = "Vui lòng xem chi tiết lương trong tập tin đính kèm email này.";
     //Gửi mail
     SmtpClientEx.QuickSendSmartHost("protocolvn.net", 25, "", message);
 }
示例#58
0
 public MimeSignature(int offset, string hex, Mime mime)
     : this(0, new byte[0], mime) { }