Пример #1
0
        private void DisplatchMailTest(interoperabilita.CalendarMail.MailRequest request)
        {
            string   err        = string.Empty;
            SvrPosta mailserver = null;

            try
            {
                //mailserver = new SvrPosta(
                //    "sendm.cert.legalmail.it", "KIT00427", "WX0UV8U8", "465",
                //    System.IO.Path.GetTempPath(), CMClientType.SMTP, "1", "0");

                mailserver = new SvrPosta(
                    "freesmtp.valueteam.com", "", "", "25",
                    System.IO.Path.GetTempPath(), CMClientType.SMTP, "0", "0");

                mailserver.connect();
                mailserver.sendMail(
                    "*****@*****.**",
                    "*****@*****.**",
                    null,
                    null,
                    "Reminder",
                    "This is a test body",
                    CMMailFormat.Text,
                    GetMailAttachment(request),
                    out err);

                if (!string.IsNullOrEmpty(err))
                {
                    throw new Exception(err);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (mailserver != null)
                {
                    mailserver.disconnect();
                }
            }
        }
Пример #2
0
        private void DispatchMail(interoperabilita.CalendarMail.MailRequest request)
        {
            string   err        = string.Empty;
            SvrPosta mailserver = null;

            try
            {
                mailserver = new SvrPosta(
                    request.Sender.Host,
                    request.Sender.UserName,
                    request.Sender.Password,
                    request.Sender.Port.ToString(),
                    System.IO.Path.GetTempPath(),
                    CMClientType.SMTP,
                    "1",
                    "0");

                mailserver.connect();

                mailserver.sendMail(
                    request.Sender.SenderEMail,
                    request.To[0],
                    request.Subject,
                    request.Body,
                    GetMailAttachment(request)
                    );

                if (!string.IsNullOrEmpty(err))
                {
                    throw new Exception(err);
                }
            }
            finally
            {
                if (mailserver != null)
                {
                    mailserver.disconnect();
                }
            }
        }
Пример #3
0
        private static bool creaMail(string subject, string bodyMail, string server, string mailMitt, string smtp_user, string smtp_pwd, string mailDest, string mailDestCC, string port, string SmtpSsl, string PopSsl, string smtpSTA, string X_TipoRicevuta, CMAttachment[] attachments, CMMailFormat format, out string statusString)
        {
            bool retValue = false;

            logger.Debug("Start");
            SvrPosta svr = new SvrPosta(server,
                                        smtp_user,
                                        smtp_pwd,
                                        port,
                                        null,
                                        CMClientType.SMTP, SmtpSsl, PopSsl, smtpSTA);

            try
            {
                svr.connect();
                List <CMMailHeaders> headers = new List <CMMailHeaders>();
                if ((X_TipoRicevuta != null) && (X_TipoRicevuta != string.Empty))
                {
                    headers.Add(new CMMailHeaders {
                        header = "X-TipoRicevuta", value = X_TipoRicevuta
                    });
                }

                svr.sendMail(mailMitt, mailDest, mailDestCC, String.Empty, subject, bodyMail, format, attachments, out statusString);
                //svr.sendMail(mailMitt, mailDest, mailDestCC, String.Empty, subject, bodyMail, CMMailFormat.Text, attachments,out statusString);
                retValue = true;
            }
            catch (Exception e)
            {
                logger.ErrorFormat("Invio Mail traimte creaMail con errore {0} : {1} ", e.Message, e.StackTrace);
                errorMessage = e.Message;
                throw e;
            }
            finally
            {
                svr.disconnect();
            }
            logger.Debug("End");
            return(retValue);
        }