Tech Note 32: Sending Mail

Aug 23, 2010

© NSB Corporation. All rights reserved.

 

It's easy to send mail messages from NS Basic/CE.

The method that follows opens up Pocket Outlook and creates a normal mail message. Next time you connect, it will be sent. While you could also create and send the message directly using Winsock, that method would only work if you were connected at the time. This method gives much more flexibilty and is simpler as well.

This method will work on Windows CE devices that have the PMail program installed. It is normally in the \windows folder.

q=chr(34)
eTo="-TO " & q & "info@nsbasic.com" & q
eSubject="-SUBJECT " & q & "Email sent from NS Basic/CE" & q
eBody="-BODY " & q & "Hello, NS Basic people!" & q
shellExecute "open","tmail.exe " & eTo & eSubject & eBody 
or, using another formatting standard,
eTo="mailto:" & "info@n..."
eSubject="?subject=" & "Email sent from NS Basic/CE on a 2002 device!"
eBody="&body=" & "Hello, NS Basic people!"
eAttachment="&attach=" & "benchmark.nsb"
shellExecute "open","tmail.exe", eTo & eSubject & eBody

Here's a sample with an attachment:
Thanks to Giuseppe Mastrangelo

q=chr(34)
ShellExecute "open", "\Windows\tmail.exe", " -To " & q & "test@test.com" & q & " -subject " & q & "SendOrder" & q & " -Body " & q & "Order of 20/08/10" & q & "-attach " & q & "\order.txt" & q

In some versions of Windows CE, such as Pocket PC 2000, the mail program is called pmail.exe, not tmail.exe. The shellExecute line needs to be changed.

 

The following arguments are supported in the tmail.exe (or pmail.exe) command:

-ATTACHMENT

File to attach (needs Pocket Outlook 3.0)

-BCC

Email to Send Blind copy to

-BODY

Body of message

-CC

Email to Send copy to

-SUBJECT

Subject of message

-TO

Email address to send to