As part of researching a project I noticed that PowerShell has a cmdlet
called Send-MailMessage which can send an SMTP mail.

It supports HTML body or plain text, multiple recipients,
attachments, priority, failure notification, SSL/TLS and SMTP
authentication if needed.

(I suspect it is using the .Net System.Net.Mail.SmtpClient namespace
internally)

I have knocked up a quick class to demonstrate how to use it to send
SMTP email on the VFP Wiki:
http://fox.wikis.com/wc.dll?Wiki~SendSmtpEmailWithPowershell

Broadly speaking the class wraps functionality that will generate a
PowerShell script file (.PS1) and then run that using Windows
Scripting Host.

One drawback is that it doesn't support inline images. So to include an
image in a HTML body you need to use an image tag with a resolvable URL
to the image, meaning resolvable by the recipient so either in a public
location on your own server, or on a third-party content server.

The way round that is inline images, where you add an inline image and
then just refer to it with a ContentID in the <img> tag, i.e.:

<img src="cid:mylogo">

The comments in the PRG refer to an enhanced version of the Send-
EmailMessage cmdlet that *does* support inline images, so go for that if
you need to.

You could look on this as analogous to using Blat from VFP, except
without the faff involved in using Stunnel to overcome Blat's lack of
SSL/TLS support. That support is vital for for sending via Exchange
Online, Gmail and so on.

The PRG requires at least PowerShell 3.0, which will be already present
on anything running Windows 7 SP1 onward, or Windows Server 2008 SP1/
Windows Server 2008 R2 onward on the server side. So forget about it on
XP or Vista.




--
  Alan Bourke
  alanpbourke (at) fastmail (dot) fm
 
 


--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/1447322473.2704697.436910497.0d4b7...@webmail.messagingengine.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to