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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating an action with a BAT file???

Status
Not open for further replies.

Dklein

IS-IT--Management
Nov 9, 2001
33
US
Hello,

I hope someone could help but I've been tasked with automating an action using a BAT file and I've no idea where to start. Basically what i'm trying to do is automate a text file being attached to an e-mail in Lotus Notes and sending to a recipient. I'm not sure if a BAT file is the way to go or if anyone could suggest an eaiser option?

I would appreciate it if someone could help.

Thanks in advance.
Dklein.
 
Hi there,

I don't know how to do this with a .bat file, but what you could also do is use Automation. You can do almost do everything in vba: compose a message, adress it, attach a file and send it. You can add all kind of options. Hereby I include code I used successfully to try if it's possible. It works with Access 97 and Notes 5.0.6a (and maybe with other combinations). If you want to know more about how to use Automation, just type in one of the keywords from the code below in a search engine on the internet, and no doubt you'll find out what you are looking. Here comes the code:

Function Create_Mail(err_subject$, err_body$)

Const ERR_MEMOFAILED = "Unable to compose new mail memo!"

Dim Ns As Object
Dim WorkSp As Object
Dim NdBase As Object
Dim doc As Object

Dim vntMailServer As Variant
Dim vntMailFile As Variant
Dim strNotesPath$, vntRetappl
Dim strdocsub$, strdocbody$
Dim newitem As Object
Dim newobject As Object
Dim sAttFile As String

On Error GoTo Err_Create_Mail

strdocsub$ = err_subject$
strdocbody$ = err_body$

'Create a reference to the externally created Notes-object
Set Ns = CreateObject("Notes.NotesSession")

'Get the Server- and the Database-ID
vntMailServer = Ns.GETENVIRONMENTSTRING("MailServer", True)
vntMailFile = Ns.GETENVIRONMENTSTRING("MailFile", True)

'Connect to the database in one of the two underlying methods
Set NdBase = Ns.GETDATABASE(CStr(vntMailServer), CStr(vntMailFile))

'Create a new document
NdBase.OPENMAIL
Set doc = NdBase.CreateDocument()

doc.SendTo = "pgransbergen@hotmail.com"
doc.Subject = "Felicitaties!"
'sAttFile = "c:\a.jpg"
'Set newobject = newitem.EMBEDOBJECT(EMBED_ATTACHMENT, "", sAttFile)
doc.Body = "Gefeliciteerd!"

doc.Form = "Memo"
doc.ExcludeFromView = "D"
doc.SaveMessageOnSend = True
doc.Send (False)

Exit_Create_Mail:

Set doc = Nothing
Set NdBase = Nothing
Set WorkSp = Nothing
Set Ns = Nothing
Exit Function

Err_Create_Mail:

On Error Resume Next
MsgBox ERR_MEMOFAILED & " " & Err.Number

Resume Exit_Create_Mail

End Function
 
The solution already given is great, but in our situation we were running a nonMS email client. To get around the problem of automatic mailouts, I used a freeware program called BLAT! (available from You can then set up batch files to attach your text file and send it. I use NT Scheduled tasks to run a program to create the files, then a batch program which checks if the text files exist, and if 'yes', email them and then delete the text files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top