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.
David Willingham (2021). READMAIL (https://www.mathworks.com/matlabcentral/fileexchange/33684-readmail), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
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');
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.
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 ******
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?
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!