Exemplo n.º 1
0
        private static int SendEmail()
        {
            Guid Sender = Guid.Parse("49A84FC4-0718-4C17-89F9-E7CCA762B1F2"); // ("004b37c1-70b8-4071-98ab-0bb73c466d00");
            Guid Receiver = Guid.Parse("31A9DE51-C207-4A73-919C-21521F17FEF9");
            SendMail _SendMail = new SendMail();

            string conn = "Server=.;Database=AFRP;Persist Security Info=True;User ID=UniCloud;Password=fleet@XMZZ";

            TestData td = new TestData(conn);
            Guid gd = td.GetLastAircraftPlan();

            EncodeModel _EModel = new EncodeModel(conn);
            var obj = _EModel.EncodePlan(gd);

            if (obj != null)
            {
                return _SendMail.SendEntity(conn, Sender, Receiver, obj, "Plan", "Plan");
            }
            else
                return -1;
        }
Exemplo n.º 2
0
 /// 民航局批文
 /// 发改委批文
 /// <summary>
 ///     通过邮件发送数据文件的方法
 /// </summary>
 /// <param name="currentAirlines"></param>
 /// <param name="obj">发送的对象</param>
 /// <param name="mailSubject">发送邮件的主题</param>
 /// <param name="attName">附件的名称</param>
 private bool TransferMail(Guid currentAirlines, object obj, string mailSubject, string attName)
 {
     var caacGuid = Guid.Parse("31A9DE51-C207-4A73-919C-21521F17FEF9");
     var dbSender = _mailAddressRepository.Get(currentAirlines);
     var dbreceiver = _mailAddressRepository.Get(caacGuid);
     if (dbSender == null)
     {
         return false;
     }
     if (dbreceiver == null)
     {
         return false;
     }
     var sender = new System.Net.Mail.MailAddress(dbSender.Address, dbSender.DisplayName);
     var receive = new System.Net.Mail.MailAddress(dbreceiver.Address, dbreceiver.DisplayName);
     //邮件中增加航空公司信息
     var airlines = _airlinesRepository.Get(currentAirlines);
     if (airlines != null)
     {
         mailSubject = airlines.CnName + "发送" + mailSubject;
     }
     var stream = ModelObjToAttachmentStream(obj);
     //发送
     var sm = new SendMail();
     var message = sm.GenMail(sender, receive, stream, mailSubject, attName);
     var blSend = sm.SendNormalMail(TransformMailAddress(dbSender), message);
     if (blSend == -1)
     {
         return sm.SendNormalMail(TransformMailAddress(dbSender), message) == 0;
     }
     return blSend == 0;
 }