watched folder, then send email..... help please

hi all

I’m very new to applescript, and could really do with a shade of help.

I would like to be able to have a “watched folder” and when I dump .pdf files inside this folder, I would like to fire-up my email software (currently Outlook Express) and send an email to my client telling him to access the “watched folder” (on our network)…

I know you are all thinking, why not just email my client the .pdf files… well his email software is so old our attachments get corrupted and/or go missing… can anyone help point me in the right direction…?

I have found some applescript examples on this discussion forum but I can’t get them to work properly…

I’m using OS 9.2.2

cheers ears

Az
:cry:

…forgot to add, this is what I’ve got so far…

set the_recipient to “testing@myEmailAddress.com
set the_subject to “please check this”
set the_content to “hi there, your files are waiting”

on adding folder items to myFolder after receiving added_items
repeat with each in added_items
tell application “Outlook Express”
make new draft window with properties ¬
{to recipients:the_recipient, subject:the_subject, content:the_content}
save window 1
send front window
end tell
end repeat
end adding folder items to

what am I doing wrong? as It doesn’t work, I keep getting an error -2753

Az

Many time since last time I scripted Outlook, but perhaps this can help you:

make new draft window at out box folder with properties...

This works for me on 8.6 thru 9.2 running OE 5

I think the source of your error was when you set your variables for email address, subject, and recipient, you did it outside of the event handler. I got the same error but after moving that within the handler it worked fine.

Hope this helps,

(*
set the_recipient to "testing@myEmailAddress.com"
set the_subject to "please check this"
set the_content to "hi there, your files are waiting"*)


on adding folder items to myFolder after receiving added_items
	--make sure you set these variables within your event handler (on adding folder items...)
	set the_recipient to "testing@myEmailAddress.com"
set the_subject to "please check this"
set the_content to "hi there, your files are waiting"
	
	--maybe you want a separate email for each file, I thought it would be better to list the new files - up to you
	set New_Files to ""
	repeat with each in added_items
		set each to each as string --for each item added, add the file name to the empty variable we just set prior to the repeat
		set New_Files to New_Files & return & each
	end repeat
	
	set the_content to the_content & return & New_Files as string --combine your initial message with the names of your new files
	
	tell application "Outlook Express"
		set Email_Notify to make outgoing message with properties {subject:the_subject, recipient:the_recipient, content:the_content}
		send Email_Notify
	end tell
end adding folder items to

(*If your client ever upgraded their email, and you wanted to start sending the PDF's you can attach files
to this email by

1. defining a path to a file

set The_Attachment to "Mac HD:Some Folder:Some File"

2. adding that to the message properties

	tell application "Outlook Express"
		set Email_Notify to make outgoing message with properties {subject:the_subject, recipient:the_recipient, content:the_content, attachment:The_Attachment, encoding:AppleDouble}
		send Email_Notify
	end tell
*)

it worked a treat

Tell Application "Boss" 
set My_Wage to My_Wage + My_Wage  * 4
End Tell

What about that?

Have a good day

wilse :D

Wishful thinkin mate!

:?

sorry for all the dumb questions, but here’s another!
The original code works a treat, although once you deliver clients move the goal posts…
All I wanted to do was to get a BCC or CC to be sent at the same time, thought I could do it, but I can’t seem to get it right… doh!

on adding folder items to myFolder after receiving added_items 
   --make sure you set these variables within your event handler (on adding folder items...) 
   set the_recipient to "testing@myEmailAddress.com" 
set the_bcc to "testingBCC@myEmailAddress.com"
set the_subject to "please check this" 
set the_content to "hi there, your files are waiting"

Am I missing something really obvious??

wilse

As long as you ask it - it can’t be dumb. And actually this is quite a good question.
I’ve never tried to do that - and now that I look at it , doesn’t appear to be as straightforward.

This was the only way I could get it to work. Maybe someone out there knows how to directly set the BCC header in the properties of the email, I could only do it by opening the newly composed outgoing message, and setting the bcc recipients…

Your new code would be…
[/b]

   tell application "Outlook Express" 
      set Email_Notify to make outgoing message with properties {subject:the_subject, recipient:the_recipient, content:the_content} 
	open Email_Notify--open it so it is the front window
	set BCC recipients of front window to the_bcc--set the bcc recipients of the front window
      send Email_Notify 
   end tell 

Like I said - there may be a more efficient method of doing this. I don’t particularly like to depend on opening a window - and making things happen to the front window.

Best,

I’ll give it a got and see what’s what… thanks for your time.

Az

Sorry, I’m testing at Entourage… :oops: But, doesn’t this work?:

set Email_Notify to make outgoing message with properties {subject:x, recipient:y, content:z, BCC recipients:alpha}

and although Outlook claims to have sent a bcc recipient, no email other than to the original recipient every gets’ sent?

weird or what?

I’ll have a butchers to see if I can try JJ’s or a mixture of both??

Thanks for the help guys.

Az :?:

Yeah, I tried that first but get this error…

And my way seems to skip the “SEND” command.

Hmph.

Well, this seems to work just fine - I tested it and got the BCC. But it is kind of a muddled way of accomplishing something that should be done in one line.

tell application "Outlook Express"
	set Email_Notify to a reference to make outgoing message with properties {subject:the_subject, recipient:the_recipient, content:the_content}
	open Email_Notify --open it so it is the front window 
	set BCC recipients of front window to the_bcc --set the bcc recipients of the front window 
	save window the_subject
	close window the_subject
	send Email_Notify
end tell

But then I’ve never been above using muddled code.

Enjoy,