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 Version History

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 (2021). READMAIL (https://www.mathworks.com/matlabcentral/fileexchange/33684-readmail), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Alfredo Butticaz

I have the following issue

Error using actxserver (line 93)
Server creation failed. Invalid ProgID 'Outlook.Application'.

Error in Readmail (line 7)
outlook = actxserver('Outlook.Application');

esivalinp

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

Omer Yasin Birey

Sébastien MAILFERT

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

Sébastien MAILFERT

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

Abhijit Chougule

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

Florian Aendekerk

@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.

Mohammed Alabiech

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

what about sender address ??

Mohammed Alabiech

How I can connect with yahoo mail please...

Jens Koopmann

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!

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!