Ejemplo n.º 1
0
        public static void SendMailWithAttachment(string to, string subject, string content, int order_id, byte[] fileBytes, string ccTo = null, string bccTo = null, byte[] docBytes = null, string docFileName = null)
        {
            //byte[] fileBytes = new byte[16 * 1024];
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    int read;
            //    while ((read = file.Read(fileBytes, 0, fileBytes.Length)) > 0)
            //    {
            //        ms.Write(fileBytes, 0, read);
            //    }
            //    ms.ToArray();
            //}

            string smtpUsername = Common.GetAppSetting <string>(APPSETTING_USER_NAME, string.Empty);
            string smtpPswd     = Common.GetAppSetting <string>(APPSETTING_PASSWORD, string.Empty);
            List <SMTPServices.CommonAttachmentDoc> smtpServicesAttachments = new List <SMTPServices.CommonAttachmentDoc>();

            SMTPServices.CommonAttachmentDoc smtpServicesAttachment = new SMTPServices.CommonAttachmentDoc();
            smtpServicesAttachment.filename = "e-Receipt" + order_id + ".pdf";
            smtpServicesAttachment.filebyte = fileBytes;
            //byte[] contentBytes = Encoding.ASCII.GetBytes(content);
            //smtpServicesAttachment.filebyte = contentBytes;
            smtpServicesAttachments.Add(smtpServicesAttachment);

            SMTPServices.Service1Client smtpService = new SMTPServices.Service1Client();
            var response = smtpService.SendMessageAtt(smtpUsername, smtpPswd, to, ccTo, bccTo, subject, content, smtpServicesAttachments.ToArray());

            smtpService.Close();
        }
Ejemplo n.º 2
0
        public static void SendMail(string to, string subject, string content, string ccTo = null, string bccTo = null, byte[] docBytes = null, string docFileName = null)
        {
            string smtpUsername = Common.GetAppSetting <string>(APPSETTING_USER_NAME, string.Empty);
            string smtpPswd     = Common.GetAppSetting <string>(APPSETTING_PASSWORD, string.Empty);

            SMTPServices.Service1Client smtpService = new SMTPServices.Service1Client();
            var response = smtpService.SendMessage(smtpUsername, smtpPswd, to, ccTo, bccTo, subject, content);

            smtpService.Close();
        }