1

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: blah@gmail.com
To: you@gmail.com
Subject: this is a body
Body:
Line 1
Line 2
Line 3

Thank you in advance.

David Hoelzer
  • 15,862
  • 4
  • 48
  • 67
JohnnyLoo
  • 877
  • 1
  • 11
  • 22

3 Answers3

4
$ 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 "blah@gmail.com"
$ mail/subject="this is a body" 'temp' "you@gmail.com"
$ delete/nolog 'temp';*
$ goto exit
$error:
$ write sys$output "Unexpected error: " + f$message ($status)
$ goto exit
$exit:
$ exit
Jim
  • 83
  • 4
2

You can send email from the command line:

$ mail/subject="this is a body" Sys$Input you@gmail.com
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 you@gmail.com
$ delete MyMessage.txt;

Documentation is here.

HABO
  • 15,314
  • 5
  • 39
  • 57
1

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;
Luc M
  • 16,630
  • 26
  • 74
  • 89