Ejemplo n.º 1
0
        private void SetLogInfo(ObjMailElement ome, int nLMode)
        {
            string sMsg;
            string sInfo;

            sInfo = "[MD][○○時○○分]";
            sInfo = AnlizeString(ome, sInfo);
            if (nLMode == 1)
            {
                sMsg = sInfo + "に" + ome.m_sCName + "さん到着";
            }
            else if (nLMode == 2)
            {
                sMsg = sInfo + "に" + ome.m_sCName + "さん帰宅";
            }
            else
            {
                sMsg = sInfo + "に" + ome.m_sCName + "さん認証";
            }
            if (m_objCrt != null)
            {
                Type type = m_objCrt.GetType();
                if (type == typeof(C100SendMailControl))
                {
                    m_objSMC = (C100SendMailControl)m_objCrt;
                    m_objSMC.AddLstLog(sMsg);
                }
            }
            DoDispatch();
        }
Ejemplo n.º 2
0
        private void SendMail(ObjMailElement ome, int nLMode)
        {
            string sMsg;
            string sFromMail;
            string sFromName;
            string sFromPassWord;
            string sToMail;
            string sToName;
            string sSubject;
            string sBody;

            DoDispatch();
            if (nLMode == 1)
            {
                sSubject = GetArrivalSubject();
                sSubject = AnlizeString(ome, sSubject);
                sBody    = GetArrivalBody();
                sBody    = AnlizeString(ome, sBody);
            }
            else if (nLMode == 2)
            {
                sSubject = GetRetHomeSubject();
                sSubject = AnlizeString(ome, sSubject);
                sBody    = GetRetHomeBody();
                sBody    = AnlizeString(ome, sBody);
            }
            else // ファンクションが押されていないときのメール(nLMode = 0)
            {
                sSubject = "[受信者名]様へ認証のご案内";
                sSubject = AnlizeString(ome, sSubject);
                sBody    = "[受信者名]様へ\n[ユーザ名]さんは[西暦年月日]に認証されました";
                sBody    = AnlizeString(ome, sBody);
            }

            sFromName     = GetServerName();
            sFromMail     = GetServerMail();
            sFromPassWord = GetServerPassWord();

            sToMail = ome.m_sSendMail;
            sToName = ome.m_sSendName + "様";

            string url;

            //url = "http://www.unismail.net/sendmail.php";
            url = "http://www.hurrymulti.com/unis/sendmail.php";

            HttpClient httpClient = new HttpClient();
            var        aryPair    = new Dictionary <string, string>();

            aryPair["tomail"]   = sToMail;
            aryPair["toname"]   = sToName;
            aryPair["frommail"] = sFromMail;
            aryPair["fromname"] = sFromName;
            aryPair["subject"]  = sSubject;
            aryPair["body"]     = sBody;
            var content = new FormUrlEncodedContent(aryPair);
            Task <HttpResponseMessage> response = httpClient.PostAsync(url, content);

            response.Wait();
            String sRet = response.Result.Content.ReadAsStringAsync().Result;

            String[] sAry = sRet.Split(',');
            if (sAry[0] == "0")
            {
                sMsg = sSubject + "メール送信失敗(" + sToName + ")";
                if (m_objCrt != null)
                {
                    Type type = m_objCrt.GetType();
                    if (type == typeof(C100SendMailControl))
                    {
                        m_objSMC = (C100SendMailControl)m_objCrt;
                        m_objSMC.AddLstLog(sMsg);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // メールを送信
        public void SendMailLoop(ObjRecordElement record)
        {
            int    nLUid;
            int    nLTid;
            string sTName;
            string sCName;
            string sCDate;
            string sCTime;
            int    nLUserType;
            string sCUnique;
            int    nLMode;
            string sMsg;

            List <ObjMailElement>  listOME;
            List <ObjAdminElement> listOAE;
            int            max, idx;
            ObjMailElement ome;

            nLTid      = record.m_nLTid;
            sTName     = record.m_sTName;
            nLUid      = record.m_nLUid;
            sCName     = record.m_sCName;
            sCDate     = record.m_sCDate;
            sCTime     = record.m_sCTime;
            nLUserType = record.m_nLUserType;
            sCUnique   = record.m_sCUnique;
            nLMode     = record.m_nLMode;

            if (m_sBFDate == sCDate &&
                m_sBFTime == sCTime &&
                m_nBFId == nLUid)
            {
                return;
            }
            m_sBFDate = sCDate;
            m_sBFTime = sCTime;
            m_nBFId   = nLUid;

            if (nLUid == -1)
            {
                sMsg = sCDate.Substring(4, 2) + "月" + sCDate.Substring(6, 2) + "日 ";
                sMsg = sMsg + sCTime.Substring(0, 2) + "時" + sCTime.Substring(2, 2) + "分";
                sMsg = sMsg + " 認証失敗";
                if (m_objCrt != null)
                {
                    Type type = m_objCrt.GetType();
                    if (type == typeof(C100SendMailControl))
                    {
                        m_objSMC = (C100SendMailControl)m_objCrt;
                        m_objSMC.AddLstLog(sMsg);
                    }
                }
                return;
            }

            ome              = new ObjMailElement();
            ome.m_sCName     = sCName;
            ome.m_sCDateTime = sCDate + sCTime;
            ome.m_nLTid      = nLTid;
            ome.m_sTName     = sTName;
            SetLogInfo(ome, nLMode);

            if (nLMode == 1 || nLMode == 2 || nLMode == 3)
            {
                if (nLMode == 3)
                {
                    nLMode = m_nDefLMode;
                }
                else
                {
                    m_nDefLMode = nLMode;
                }
                listOME = GetMailElementList();
                max     = listOME.Count;
                for (idx = 0; idx < max; idx++)
                {
                    if (listOME[idx].m_nLUid == nLUid)
                    {
                        listOME[idx].m_sCDateTime = sCDate + sCTime;
                        listOME[idx].m_nLTid      = nLTid;
                        listOME[idx].m_sTName     = sTName;
                        try
                        {
                            SendMail(listOME[idx], nLMode);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                if (GetAdminSend() == true)
                {
                    if (GetAdminSend() == true)
                    {
                        listOAE = GetAdminElementList();
                        max     = listOAE.Count;
                        for (idx = 0; idx < max; idx++)
                        {
                            ome.m_sSendName = listOAE[idx].m_sName;
                            ome.m_sSendMail = listOAE[idx].m_sMail;
                            try
                            {
                                SendMail(ome, nLMode);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
            }
        }