File Exchange

image thumbnail

READMAIL

version 1.0.0.1 (1.51 KB) by David Willingham
Imports the text from emails into MATLAB & saves attachments from Microsoft Outlook.

8 Downloads

Updated 01 Sep 2016

View License

A simple script highlighting how you can connect to Outlook and import emails into MATLAB. It allows you to:
Import Subject Text
Import Body Text
Save attachements to the current directory.

Cite As

David Willingham (2020). READMAIL (https://www.mathworks.com/matlabcentral/fileexchange/33684-readmail), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

esivalinp

It's very useful, which gives Matlab a stronger automation capability.

Dear all, here is the solution to look inside subfolders:

% I’m looking for emails inside this location:
% Boîte de reception -> SubFolder -> SubSubFolder

%% Connecting to Outlook
outlook = actxserver('Outlook.Application');
mapi=outlook.GetNamespace('mapi');


k=0;
while(1)
k=k+1;
if(strcmp(mapi.Folders.Item(1).Folders.Item(k).Name,'Boîte de réception'))
break
end%
end

i=0;
while(1)
i=i+1;
if(strcmp(mapi.Folders.Item(1).Folders.Item(k).Folders.Item(i).Name,'SubFolder'))
break
end%if
end
m=0;


while(1)
m=m+1;
if(strcmp(mapi.Folders.Item(1).Folders.Item(k).Folders.Item(i).Folders.Item(m).Name, 'SubSubFolder'))
break
end%
end

INBOX=mapi.Folders.Item(1).Folders.Item(k).Folders.Item(i).Folders.Item(m);

Thanks to David and his colleague

Dear all,

I'm tring to read all emails Ilocated inside a specific folder, not in the current one.
Could you help me please?
Best regards.
Sébastien

Can I get the date of the first mail received ? Any command for that ?

@Mohammed Alabiech: I realize I am probably late, but for others wondering:
sender = email.get('SenderName')
Stores the name of the sender as string in variable sender.

Julian Zilg

Adriano

Koray Kirca

Hi,
I have this error. Any solutions?

Error using Interface.Microsoft_Outlook_15.0_Object_Library._Items/Item
Invoke Error, Dispatch Exception:
Source: Microsoft Outlook
Description: Array index out of bounds.

subject = firstemail.get('Subject');
body = firstemail.get('Body');

what about sender address ??

How I can connect with yahoo mail please...

Exactly what I need ******

Marc Jakobi

Hi.
Thanks for the submission. Seems to work fine. But unfortunately, only for my default outlook account. I have 3 accounts on Outlook. Do you know how I could access the e-mails on one of my secondary accounts?

Zoe Zhang

Hi David,

I get email from the same person (with the same subject)around the same time everyday. How could I edit your code so that everyday this particular email could be loaded into matlab? Thanks a lot!

Updates

1.0.0.1

Updated license

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux