JohnnyLoo
JohnnyLoo

Reputation: 927

send email from openVMS

I am not familiar with OpenVMS but I would like to understand how to write a script that will send an email whenever I call it. My understanding is that the body of the email is put in a temp file before it is converted to text and sent. How do I create this file? Do you have any examples to write a script that will send an email like this?

From: [email protected]
To: [email protected]
Subject: this is a body
Body:
Line 1
Line 2
Line 3

Thank you in advance.

Upvotes: 1

Views: 1845

Answers (3)

Jim
Jim

Reputation: 83

$ temp = f$unique() + ".tmp"
$ open/write/error=error temp 'temp'
$ write temp "line1"
$ write temp "line2"
$ write temp "line3"
$ close temp
$ define/user tcpip$smtp_from "[email protected]"
$ mail/subject="this is a body" 'temp' "[email protected]"
$ delete/nolog 'temp';*
$ goto exit
$error:
$ write sys$output "Unexpected error: " + f$message ($status)
$ goto exit
$exit:
$ exit

Upvotes: 4

Luc M
Luc M

Reputation: 17324

The answer that I saw includes the files into your body.

You maybe want to join a file... Here's how I attach a file in email:

$ UUENCODE my_file_to_attach.ext my_file_to_attach.ext
$ MAIL/SUBJECT="A subject..." my_file_to_attach.ext you@a_domain.com
$ DELETE my_file_to_attach.ext;

If you want to include a body:

$ CREATE temp.file
Hello,
    Here's the in attachment.
    Regards.
$ UUENCODE my_file_to_attach.ext my_file_to_attach.ext
$ TYPE my_file_to_attach.ext, temp.file physical_file_send.txt
$ MAIL/SUBJECT="A subject" physical_file_send.txt you@a_domain.com
$ DELETE physical_file_send.txt;, my_file_to_attach.ext;

Upvotes: 1

HABO
HABO

Reputation: 15841

You can send email from the command line:

$ mail/subject="this is a body" Sys$Input [email protected]
Line 1
Line 2
Line 3
$ exit

Normally you would create a file to send first:

$ create MyMessage.txt
Line 1
Line 2
Line 3
$ mail/subject="this is a body" MyMessage.txt [email protected]
$ delete MyMessage.txt;

Documentation is here.

Upvotes: 2

Related Questions