public string ConvertImageToBase64String(string files)
        {
            string base64String = string.Empty;
            string contentType  = string.Empty;

            if (string.IsNullOrWhiteSpace(files))
            {
                return(string.Empty);
            }

            try
            {
                if (!File.Exists(files))
                {
                    throw new Exception(string.Format("File {0} does not exists", files));
                }

                contentType = string.Format("data:image/{0};base64,", Path.GetExtension(files).TrimStart('.').ToLower());
                using (Image _image = Image.FromFile(files))
                {
                    using (MemoryStream _mStream = new MemoryStream())
                    {
                        _image.Save(_mStream, _image.RawFormat);
                        byte[] _imageBytes = _mStream.ToArray();
                        base64String = Convert.ToBase64String(_imageBytes);
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception(SmtpMessage.ErrorMessage(exception));
            }
            return(string.Format("{0}{1}", contentType, base64String).TrimStart().TrimEnd());
        }
        public string Send(string server, int serverPort, bool authentication, string userName, string password, bool enableSsl)
        {
            string str;

            try
            {
                this.message.From         = new MailAddress(this.FromAddress, this.FromName);
                this.smtpClient.Host      = server;
                this.smtpClient.Port      = serverPort;
                this.smtpClient.EnableSsl = enableSsl;
                if (!authentication)
                {
                    this.smtpClient.Credentials           = null;
                    this.smtpClient.UseDefaultCredentials = false;
                }
                else if (string.IsNullOrEmpty(userName))
                {
                    this.smtpClient.Credentials           = null;
                    this.smtpClient.UseDefaultCredentials = true;
                }
                else
                {
                    this.smtpClient.UseDefaultCredentials = false;
                    this.smtpClient.Credentials           = new NetworkCredential(userName, password);
                }
                this.ConvertBase64ImagesToContentId();
                this.smtpClient.Send(this.message);
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddHeader(string name, string value)
        {
            string str;

            try
            {
                this.message.Headers.Add(name, value);
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string DeliveryNotification(DeliveryNotificationOptions value)
        {
            string str;

            try
            {
                this.message.DeliveryNotificationOptions = value;
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddRecipientsWithDisplayName(string recipientname, string recipientaddress)
        {
            string str;

            try
            {
                this.message.To.Add(string.Format("{0} <{1}>", recipientname, SmtpMessage.RemoveSemicolonComma(recipientaddress)));
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddRecipients(string recipients)
        {
            string str;

            try
            {
                this.message.To.Add(SmtpMessage.FormatToComma(recipients));
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddAttachment(Stream attachmentStream, string attachmentName)
        {
            string str;

            try
            {
                this.message.Attachments.Add(new Attachment(attachmentStream, attachmentName));
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AppendBody(string text)
        {
            string str;

            try
            {
                MailMessage mailMessage = this.message;
                mailMessage.Body = string.Concat(mailMessage.Body, text);
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddLinkedResource(Stream resourceStream, string contentType, string contentId)
        {
            string str;

            try
            {
                LinkedResource linkedResource = new LinkedResource(resourceStream, new ContentType(contentType));
                linkedResource.ContentId = contentId;
                linkedResources.Add(linkedResource);
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddLinkedResources(string files, string contentType, string contentId)
        {
            string str;

            if (string.IsNullOrWhiteSpace(files))
            {
                return(string.Empty);
            }

            try
            {
                LinkedResource linkedResource = new LinkedResource(files, new ContentType(contentType));
                linkedResource.ContentId = contentId;
                linkedResources.Add(linkedResource);
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddAttachmentWithName(string files, string fileNames)
        {
            string str;

            try
            {
                char[]   chrArray  = new char[] { ';' };
                string[] strArrays = files.Split(chrArray);
                chrArray = new char[] { ';' };
                string[] strArrays1 = fileNames.Split(chrArray);
                bool     length     = (int)strArrays.Length == (int)strArrays1.Length;
                for (int i = 0; i < (int)strArrays.Length; i++)
                {
                    string str1 = strArrays[i].Trim();
                    if (!string.IsNullOrEmpty(str1))
                    {
                        if ((!length ? true : string.IsNullOrWhiteSpace(strArrays1[i])))
                        {
                            this.message.Attachments.Add(new Attachment(str1));
                        }
                        else
                        {
                            AttachmentCollection attachments = this.message.Attachments;
                            Attachment           attachment  = new Attachment(str1)
                            {
                                Name = strArrays1[i].Trim()
                            };
                            attachments.Add(attachment);
                        }
                    }
                }
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddAlternateView(string content, string contenttype)
        {
            string str;

            if (string.IsNullOrWhiteSpace(content) || string.IsNullOrWhiteSpace(contenttype))
            {
                return(string.Empty);
            }

            try
            {
                AlternateView alternate;
                if (string.IsNullOrWhiteSpace(contenttype))
                {
                    alternate = AlternateView.CreateAlternateViewFromString(content);
                }
                else
                {
                    ContentType mimeType = new System.Net.Mime.ContentType(contenttype);
                    alternate = AlternateView.CreateAlternateViewFromString(content, mimeType);
                }

                foreach (LinkedResource linkedResource in linkedResources)
                {
                    alternate.LinkedResources.Add(linkedResource);
                }

                MailMessage mailMessage = this.message;
                mailMessage.AlternateViews.Add(alternate);
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }
        public string AddAttachments(string files)
        {
            string str;

            try
            {
                files = SmtpMessage.FormatToSemicolon(files);
                string[] strArrays = files.Split(new char[] { ';' });
                for (int i = 0; i < (int)strArrays.Length; i++)
                {
                    string str1 = strArrays[i];
                    if (!string.IsNullOrEmpty(str1.Trim()))
                    {
                        this.message.Attachments.Add(new Attachment(str1));
                    }
                }
                str = "";
            }
            catch (Exception exception)
            {
                str = SmtpMessage.ErrorMessage(exception);
            }
            return(str);
        }