Sign in to follow this  
Followers 0
bartekd

New email -- Save to Text

33 posts in this topic

Hello All,

Is there a script that anyone has created that auto-saves incoming emails as txt in a directory? The subject and body should be readable somehow.

Share this post


Link to post
Share on other sites



Which mail client do you use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I use outlook. Either version 2000 or 2003.

Share this post


Link to post
Share on other sites

Unfortunately Outlook has to be version 2007 or later for AutoIt to be able to access events (like: "New Mail").

But you could try the other way round. Define a rule in Outlook to start your AutoIt script when a new mail arrives.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ya I could do that. Im not too sure where to start.

I want it to save the email to text and maybe delete it. Do you know how I could accomplish that?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

First step would be to verify that Outlook 2000 or 2003 let you create a rule that executes a program when a new mail arrives (named "Run a Script Rule").

I run Outlook 2010 so can't check.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes, I see the option to start an application if a email comes in. See below:

post-47970-0-17148200-1355168989_thumb.j

Share this post


Link to post
Share on other sites

Looks like you need to use VBA to process an incoming mail in Outlook 2000. VBS doesn't work according to this article or this MSDN article.

Upgrading to Outlook 2007 isn't an option? Then it could easily be written in AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

hmm, thats too bad. No I can't upgrade to 2007 because we don't have the license for it. Any other solutions?

Share this post


Link to post
Share on other sites

Have you tried to grab the text directly from the browser for this? It might be a viable alternative to trying to automate Outlook.

Share this post


Link to post
Share on other sites

Another approach is to check the inbox for new (=unread) mails in a loop.

This takes some processing power and isn't 100% save.

IIRC the OutlookEX help & support thread has an example script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ill take a look and see what I can find. The OutlookEX script is compatible with outlook 2000?

Share this post


Link to post
Share on other sites

I have tested it with Outlook 2002 (XP) and Outlook 2010. I think it should work with Outlook 2000 as well.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks again Water. ill try and let you know.

Share this post


Link to post
Share on other sites

Sorry to go back to this. I have the work around which interfaces with the outlook 2000 and saves the email to HTML. So its working ok... but I would like it to be un-attended (in case the script fails, I have to keep half an eye on it).

Is there any way of using SMTP to retrieve an email, save it as HTML to a folder, and then delete it from the email server? I looked around and there is lots of scripts for sending through SMTP but none that retrieve.

Share this post


Link to post
Share on other sites

Here is a link to a free COM object that can retrive email with POP, that you can automate with Auto-it. Download it, register it with regsvr32. Follow the documentation to create your script.

http://www.system-engine.com/EmiaCtrlLite/

Share this post


Link to post
Share on other sites

Thanks. Does that COM object support saving the HTML code of the email to a file? I can't see the instructions anywhere.

Share this post


Link to post
Share on other sites

It does. Look around the site a little it has VBscript examples to look at. I downloaded it and used it. Seems to be what you are asking for. It will download the messages to a string which you can then save to a file.

Share this post


Link to post
Share on other sites

Would you be able to provide me the piece of code of what to do? Sorry I am not too familiar with VB and what needs to be done.

Share this post


Link to post
Share on other sites

You must register the dll first. Fill in the

server,port,username,password in the functions. Also make sure if you are using a 64 bit OS that you run the script in 32bit mode or it will not work

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=pop_test.exe
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

dim $stat
$pop_mail = ObjCreate("EmiaLITE.SendRetrieve")

$pop_mail.set_POP3(server,port,username,password)

$stat = $pop_mail.get_stat()
;this will get how many emails you have and the size of the mail box
ConsoleWrite($stat.MessageCount&@CRLF&$stat.BoxSize&@CRLF)
$pop_mail = ""
$pop_mail = ObjCreate("EmiaLITE.SendRetrieve")
$pop_mail.set_POP3(server,port,username,password)
$pop_mail.connect_messageX_POP3()
;this will retrieve the 1st email from the server but not delete it off the server and display it in the console
;you can assign this to a variable and save it to a text file
;you will need to manipulate the string to get what you want from the string


ConsoleWrite($pop_mail.get_message(1,0))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0