Re: sending email via idl? [message #82738 is a reply to message #60767] |
Fri, 11 January 2013 06:18   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Friday, January 11, 2013 2:26:30 PM UTC+1, alx wrote:
> Le mercredi 4 juin 2008 19:41:49 UTC+2, sudha a écrit :
>
>> Has anyone had any experience in writing an idl program to send email?
>
>> My software needs to have the ability to email an image attachment,
>
>> either when the user clicks a button, or as a notification at the end
>
>> of some computation.
>
>>
>
>> Thanks!
>
>>
>
>> Sudha
>
>
>
> I never did it.
>
> I guess that the "modern" Windows solution would be to spawn a powershell script using the built-in SmtpClient.Send function.
>
> alain.
Thanks Alain,
I'm not that modern and didn't know what the powershell was.
I googled a bit and found this: http://serverfault.com/questions/110057/easiest-way-to-send- an-email-from-the-command-line-using-windows-2003-r2
where a one line spawn command is given:
To make a one liner, save the following to a powershell script file (sendmail.ps1):
param(
[string] $From = "from@example.com",
[string] $To = "to@example.com",
[string] $Title = "title",
[string] $Body = "body"
)
$SmtpClient = New-Object System.Net.Mail.SmtpClient
$SmtpServer = "your.mail.host.com"
$SmtpClient.host = $SmtpServer
$SmtpClient.Send($From,$To,$Title,$Body)
and then call the powershell:
powershell.exe c:\path\to\sendmail.ps1 "from@example.com" "to@example.com" "title" "body"
Just have to sort out the credentials (user and pwd)...
Cheers,
Helder
|
|
|