Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SCRIPT HOW TO SEND EMAIL

Status
Not open for further replies.

nguyenb9

Technical User
Apr 1, 2003
55
US
Does anyone have any experience using send email. If anyone does please provide some sample script.

I have a script that run successfully, and I would like to and send email when it complete.

thanks,
 
I have a couple samples at - there are two examples illustrating how to use mapisend (useful if you have a program such as Outlook or Outlook Express on the machine), and another example that shows how to generate emails through Procomm's built-in mail client.


aspect@aspectscripting.com
 
I execute both scripts, and don't work. All it does it bring up the Internet "Setup" screen. What do I need to do to modify the script to make it works.

thanks,

 
Do you already have Outlook or Outlook Express (or another MAPI-compliant mail program) installed and configured on the machine? This is necessary if you using the mapisend command.

If you are trying to use the script that sends email through Procomm's mail client, then you will need to configure it with the information it needs (mail server, username, password, etc.) before the script will work succesfully.


aspect@aspectscripting.com
 
I got the sample from the site you recommended. I modified the script and it didn't run can you verify the script to see where I go wrong?

;****Multiple Email files script*****************************************************************
;Script written 12/03/03 by Stuart Pearson
;The aEmail_files array holds the strings that detail the list of files to attach to the email
;When the files are added the script checks that the length of the `aEmail_files[n]` string is
;under 255 characters. If adding the file increases the length above 255 a new email is created,
;this process continues until all the files specified are included.
;The script has been taken from a larger script where the various parameters i.e. Email addresses
;and the files to send are already known, for this reason I have included multiple input boxes
;to get this information.
;************************************************************************************************
proc main
string sEmailfile = "c:\sas\sastxout" ;Receives string input of file specificaton
string aEmail_files[100] ;string array for files to attach to each email
string sEmail_lne ;string for dialogbox error message
string sEmail_temp ;string to
integer iCounter = 1 ;integer used for various loops
integer iE_counter = 1 ;integer to log number of files to send
integer iEmail_Length ;integer to record length of email file string
integer iTemp_Length ;integer to check modified email string length
;is less than 255
string sMailLogon = "bnguyen" ;Mail logon/profile name
string sMailPassword = "Jen123" ;Not needed if using Exchange Server
string sTo = "bao.nguyen@logixcom.com" ;Recipients as they appear in the Outlook address book or enter just email address
string sCC = "" ;CC recipients
string sBCC = "" ;BCC recipients
string sSubject = "Email from Procomm" ;Subject of the message
string sContents = "test mail" ;text appearing in body of message
string sMailError ;Holds any returned errors
sdlginput "Enter Mail Logon/profile Name" "Logon/Profile Name:" sMailLogon DEFAULT
sdlginput "Enter Mail Password - not needed for Exchange Server" "Logon Password" sMailPassword DEFAULT
sdlginput "Enter Email Send Address" "To:" sTo DEFAULT
sdlginput "Enter Email CC Addresse(s) seperated by ;" "CC:" sCC DEFAULT
sdlginput "Enter Email BCC Addresse(s) seperated by ;" "BCC:" sBCC DEFAULT
sdlginput "Enter File Specification" "File Spec." sEmailfile DEFAULT
while iCounter !=100
aEmail_files[iCounter]=""
iCounter ++
endwhile
iE_counter=1

if findfirst sEmailfile
strlen aEmail_files[iE_counter] iTemp_Length
strlen $filespec iEmail_Length
if (iTemp_Length + iEmail_Length) < 255
strcat aEmail_files[iE_counter] $filespec
strcat aEmail_files[iE_counter] &quot;;&quot;
else
iE_counter ++
strcat aEmail_files[iE_counter] $filespec
strcat aEmail_files[iE_counter] &quot;;&quot;
endif

while findnext
sEmail_temp=aEmail_files[iE_counter]
strlen aEmail_files[iE_counter] iTemp_Length
strlen $filespec iEmail_Length
if (iTemp_Length + iEmail_Length) < 255
strcat aEmail_files[iE_counter] $filespec
strcat aEmail_files[iE_counter] &quot;;&quot;
else
iE_counter ++
strcat aEmail_files[iE_counter] $filespec
strcat aEmail_files[iE_counter] &quot;;&quot;
endif
if iE_counter==100
dialogbox 1 41 31 264 66 15 &quot;WARNING&quot;
text 1 32 26 200 12 &quot;**NUMBER of EMAILs too high (>99)**&quot; center
enddialog
pause 1
exitwhile
endif
endwhile
endif
iE_counter=1
if nullstr aEmail_files[1]
dialogbox 1 41 31 264 66 11 &quot;INFORMATION&quot;
text 1 72 26 120 12 &quot;**NO EMAILS TO PROCESS**&quot; center
enddialog
goto end_email
endif
while not stricmp aEmail_files[iE_counter] &quot;&quot;
mapisend sMailLogon sMailPassword sTo sCC sBCC sSubject sContents aEmail_files[iE_counter] sMailError
if SUCCESS
dialogbox 1 41 31 264 66 11 &quot;INFORMATION&quot;
text 1 72 26 120 12 &quot;**EMAILS PROCESSED OK**&quot; center
enddialog
else
strfmt sEmail_lne &quot;**EMAIL ERROR DETECTED** (%s)&quot; sMailError
dialogbox 1 41 31 264 66 11 &quot;INFORMATION&quot;
text 1 19 26 227 12 sEmail_lne center
enddialog
pause 1
endif
iE_counter ++
endwhile

end_email:
pause 1
dlgdestroy 1 cancel
endproc
 
I did configured mail server in procomm, and I can go to procomm and email it manually. But when I run the script, it don't seems to work.

thanks
 
The script you modified is one that requires a MAPI-compliant program (like Outlook) to send the email. Procomm's mail client does not fall under this category, though. Do you have Outlook on that machine? If not, you'll either need to modify the mail.was script (located about halfway down the samples page) or install Outlook or a similar mail program to use the script you modified.


aspect@aspectscripting.com
 
Using Outlook and set to MS Exchange Server.

What I found was that the string sMailLogon = &quot;&quot; ;Mail logon/profile name

needed to be set to something entirely different than I would have figured. It had to be set to the value which can be found by going to Outlook's Tools/Options Mail Services tab: If using MS Exchange Server at the top you'll probably have a check mark by 'Always use this Profile. The profile name in the field to the right of this is what I had to put in my 'sMailLogon' variable.

In my case it is set to: &quot;CompanyName Mail&quot;
In th drop down I noticed the default: &quot;MS Exchange Settings&quot;.

Hope this helps using the MapiSend with Outlook. DT
 
Good point, I have this tidbit mentioned elsewhere on my site, but don't have a comment about it in the sample scripts. I'll make that change later today.


aspect@aspectscripting.com
 
It is working great! Thanks,

Another question. How can I eliminate all the prompts? My script is going to run automatically with any human intervention and I would like to send email out every time my procomm script is complete. This would be helpfull.

Thank you.
 
Which script are you running, the one that uses Procomm's email client or the other script that uses mapisend? Some versions of Outlook do not allow other programs to send mail through Outlook automatically (a message box is displayed warning of this fact), but I saw a program over the weekend that will sit in the system tray and answer yes to this prompt. I have it bookmarked on my home machine if you need it.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top