Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sending an email
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
open System open System.Net.Mail // open System.Configuration let server = "smtp.myserver.com" // ConfigurationManager.AppSettings.["mailserver"] let sender = "nospam@mydomain.com" // ConfigurationManager.AppSettings.["mailsender"] let password = "abc123" // ConfigurationManager.AppSettings.["mailpassword"] |> my-decrypt let port = 587 let sendMailMessage email name topic msg = let msg = new MailMessage( sender, email, topic, "Dear " + name + ", <br/><br/>\r\n\r\n" + msg) msg.IsBodyHtml <- true let client = new SmtpClient(server, port) client.EnableSsl <- true client.Credentials <- System.Net.NetworkCredential(sender, password) client.SendCompleted |> Observable.add(fun e -> let msg = e.UserState :?> MailMessage if e.Cancelled then ("Mail message cancelled:\r\n" + msg.Subject) |> Console.WriteLine if e.Error <> null then ("Sending mail failed for message:\r\n" + msg.Subject + ", reason:\r\n" + e.Error.ToString()) |> Console.WriteLine if msg<>Unchecked.defaultof<MailMessage> then msg.Dispose() if client<>Unchecked.defaultof<SmtpClient> then client.Dispose() ) // Maybe some System.Threading.Thread.Sleep to prevent mail-server hammering client.SendAsync(msg, msg)
Show compiler warnings
[
+
]
Show input
Compilation time: 3.08 sec, absolute running time: 0.18 sec, cpu time: 0.13 sec, memory peak: 5 Mb, absolute service time: 3,27 sec
edit mode
|
history
|
discussion