Exemple #1
0
        private void sendPoster(string filename)
        {
            FileInfo f = new FileInfo(filename);
            string   local_filename = f.Name;

            Chilkat.MailMan mailman = new Chilkat.MailMan();
            bool            success;

            success = mailman.UnlockComponent("HAFSJOMAILQ_9QYSMgP0oR1h");
            if (success != true)
            {
                throw new Exception(mailman.LastErrorText);
            }

            //  Use the GMail SMTP server
            mailman.SmtpHost = Program.Smtphost;
            mailman.SmtpPort = int.Parse(Program.Smtpport);
            mailman.SmtpSsl  = bool.Parse(Program.Smtpssl);

            //  Set the SMTP login/password.
            mailman.SmtpUsername = Program.Smtpuser;
            mailman.SmtpPassword = Program.Smtppasswd;

            //  Create a new email object
            Chilkat.Email email = new Chilkat.Email();

            email.Subject = "Puls3060 Regnskab: " + local_filename;
            email.Body    = "Puls3060 Regnskab: " + local_filename;

            //email.AddTo(Program.MailToName, Program.MailToAddr);
            email.From    = Program.MailFrom;
            email.ReplyTo = Program.MailReply;
            email.AddBcc(Program.MailToName, Program.MailToAddr);

            email.AddFileAttachment(filename);
            email.UnzipAttachments();

            success = mailman.SendEmail(email);
            if (success != true)
            {
                throw new Exception(email.LastErrorText);
            }
        }