Ejemplo n.º 1
0
        public BaseReturn <bool> sendMailReply(Email mail, string replymessage)
        {
            BaseReturn <bool> baseObject = new BaseReturn <bool>();

            try
            {
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                var enc1252 = Encoding.GetEncoding(1252);

                mail.To   = mail.From;
                mail.From = Config.serviceMailId;
                mail.Body = replymessage;


                var msg = new AE.Net.Mail.MailMessage
                {
                    Subject     = "RE : " + mail.Subject,
                    Body        = mail.Body,
                    ContentType = "text/html",
                    From        = new MailAddress(mail.From)
                };

                msg.To.Add(new MailAddress(mail.To));

                msg.ReplyTo.Add(new MailAddress(mail.From));

                mail.CC.Split(',').ToList().ForEach(addr =>
                {
                    if (addr.Trim() != "")
                    {
                        msg.Cc.Add(new MailAddress(addr));
                    }
                });

                var msgStr = new StringWriter();
                msg.Save(msgStr);

                var result = _service.Users.Messages.Send(new Message
                {
                    ThreadId = mail.MailId,
                    Id       = mail.MailId,
                    Raw      = CommonFunctions.Base64UrlEncode(msgStr.ToString())
                }, "me").Execute();

                saveReplyMailInfo(mail);
                baseObject.Success = true;
                baseObject.Data    = true;
            }
            catch (Exception ex)
            {
                baseObject.Success = false;
                baseObject.Message = "Error Occured.";
            }
            return(baseObject);
        }