Re: sending email via idl? [message #82737 is a reply to message #60767] |
Fri, 11 January 2013 07:22   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le vendredi 11 janvier 2013 15:18:41 UTC+1, Helder a écrit :
> 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
Hi Helder,
Powershell.exe is the new command line processor for Windows systems (not so new since it was already present in Windows Server 2003, and maybe also in 2000). It replaces the old-style, DOS-like cmd.exe command processor. It is quite powerfull, and resembles the famous DCL from Vax VMS.
alain.
|
|
|