2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,6 +1,11 @@
Write a function to send an email. The function should have parameters for setting From, To and Cc addresses; the Subject, and the message text, and optionally fields for the server name and login details.
;Task:
Write a function to send an email.
The function should have parameters for setting From, To and Cc addresses; the Subject, and the message text, and optionally fields for the server name and login details.
* If appropriate, explain what notifications of problems/success are given.
* Solutions using libraries or functions from the language are preferred, but failing that, external programs can be used with an explanation.
* Note how portable the solution given is between operating systems when multi-OS languages are used.
<br>
(Remember to obfuscate any sensitive data used in examples)
<br><br>

View file

@ -1,14 +1,8 @@
USING: kernel accessors smtp io.sockets namespaces ;
IN: learn
: send-mail ( from to cc subject body -- )
"smtp.gmail.com" 587 <inet> smtp-server set
smtp-tls? on
"noneofyourbuisness@gmail.com" "password" <plain-auth> smtp-auth set
<email>
swap >>from
swap >>to
swap >>cc
swap >>subject
swap >>body
send-email ;
USING: accessors io.sockets locals namespaces smtp ;
IN: scratchpad
:: send-mail ( f t c s b -- )
default-smtp-config "smtp.gmail.com" 587 <inet> >>server
t >>tls?
"my.gmail.address@gmail.com" "qwertyuiasdfghjk" <plain-auth>
>>auth \ smtp-config set-global <email> f >>from t >>to
c >>cc s >>subject b >>body send-email ;

View file

@ -0,0 +1,16 @@
program sendmail
use ifcom
use msoutl
implicit none
integer(4) :: app, status, msg
call cominitialize(status)
call comcreateobject("Outlook.Application", app, status)
msg = $Application_CreateItem(app, olMailItem, status)
call $MailItem_SetTo(msg, "somebody@somewhere", status)
call $MailItem_SetSubject(msg, "Title", status)
call $MailItem_SetBody(msg, "Hello", status)
call $MailItem_Send(msg, status)
call $Application_Quit(app, status)
call comuninitialize()
end program

View file

@ -0,0 +1,14 @@
[hashtable]$mailMessage = @{
From = "weirdBoy@gmail.com"
To = "anudderBoy@YourDomain.com"
Cc = "daWaghBoss@YourDomain.com"
Attachment = "C:\temp\Waggghhhh!_plan.txt"
Subject = "Waggghhhh!"
Body = "Wagggghhhhhh!"
SMTPServer = "smtp.gmail.com"
SMTPPort = "587"
UseSsl = $true
ErrorAction = "SilentlyContinue"
}
Send-MailMessage @mailMessage

View file

@ -0,0 +1,13 @@
import win32com.client
def sendmail(to, title, body):
olMailItem = 0
ol = win32com.client.Dispatch("Outlook.Application")
msg = ol.CreateItem(olMailItem)
msg.To = to
msg.Subject = title
msg.Body = body
msg.Send()
ol.Quit()
sendmail("somebody@somewhere", "Title", "Hello")

View file

@ -0,0 +1,14 @@
library(RDCOMClient)
send.mail <- function(to, title, body) {
olMailItem <- 0
ol <- COMCreate("Outlook.Application")
msg <- ol$CreateItem(olMailItem)
msg[["To"]] <- to
msg[["Subject"]] <- title
msg[["Body"]] <- body
msg$Send()
ol$Quit()
}
send.mail("somebody@somewhere", "Title", "Hello")

View file

@ -1,4 +1,5 @@
#!/usr/bin/txr
#!/usr/bin/txr
@(next :args)
@(cases)
@TO
@ -11,11 +12,11 @@
@(or)
@ (throw error "must specify at least To and Subject")
@(end)
@(next "-")
@(next *stdin*)
@(collect)
@BODY
@(end)
@(output `!mail -s "@SUBJ" -c "@CC" "@TO"`)
@(output (open-command `mail -s "@SUBJ" -a CC: "@CC" "@TO"` "w"))
@(repeat)
@BODY
@(end)

View file

@ -0,0 +1,19 @@
Option Explicit
Const olMailItem = 0
Sub SendMail(MsgTo As String, MsgTitle As String, MsgBody As String)
Dim OutlookApp As Object, Msg As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set Msg = OutlookApp.CreateItem(olMailItem)
With Msg
.To = MsgTo
.Subject = MsgTitle
.Body = MsgBody
.Send
End With
Set OutlookApp = Nothing
End Sub
Sub Test()
SendMail "somebody@somewhere", "Title", "Hello"
End Sub