[Mono-list] send a mail using mono

Rolando Martinez rolandomartinezg at gmail.com
Mon Sep 22 01:13:41 EDT 2008


okay,
I tried the code below and this is not working in ms.net too.
So that I tried the next code and is working in .net but in mono no :(

(this code is using the obsolete namespace System.Web.Mail)

MailMessage mailMsg = new MailMessage();
            mailMsg.From = "rolandomartinezg at gmail.com";
            mailMsg.To = to;
            mailMsg.Cc = cc;
            mailMsg.Subject = subject;
            mailMsg.BodyFormat = MailFormat.Text;
            mailMsg.Body = body;
            mailMsg.Priority = MailPriority.High;

            // Smtp configuration
            SmtpMail.SmtpServer = "smtp.gmail.com";
            // - smtp.gmail.com use smtp authentication
            mailMsg.Fields.Add
            ("
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            mailMsg.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendusername", "
rolandomartinezg at gmail.com");
            mailMsg.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendpassword",
            "xxxx");
            // - smtp.gmail.com use port 465 or 587
            mailMsg.Fields.Add
            ("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"465");
            // - smtp.gmail.com use STARTTLS (some call this SSL)
            mailMsg.Fields.Add
            ("http://schemas.microsoft.com/cdo/configuration/smtpusessl",
"true");
            // try to send Mail
            try
            {
                SmtpMail.Send(mailMsg);
                return "";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }

Some example using google mail (or any smtp server) with mono??

Thanks,
Rolando



From: "Chris Howie" <cdhowie at gmail.com>
Subject: Re: [Mono-list] send a mail using mono
To: "Mono mailing list" <mono-list at lists.ximian.com>
Message-ID:
       <3d2f29dc0809092058s1f7d10f8t9efb82bdeddacace at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

On Tue, Sep 9, 2008 at 9:03 PM, Christian L?pez Esp?nola
<penyaskito at gmail.com> wrote:
> Does a telnet to smtp.uach.cl:465? Do this work with MS.net? Are
> gmail.com users valid for this SMTP server?

Also, port 465 is typically used for TLS-encrypted SMTP.  I believe
the framework supports SSL (if you set the appropriate property) but I
don't think it supports TLS.

--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080922/43754aa0/attachment-0001.html 


More information about the Mono-list mailing list