I want to send a picture by email to an email address at "Outlook.com" using MATLAB

Hi
I want to send a specific picture to an email address using Matlab gui
I know how to browse and select a picture, but I want to send the picture that I selected to send it to any email.
Thanks :)
See attachment.

 Accepted Answer

1 Comment

% NOTE: CHANGE THE NEXT FEW LINES OF CODE WITH TO REFLECT YOUR SETTINGS.
myUserName = 'me';
myPassword = 'thisismypassword';
mySMTP = 'myserver.mydomain.com';
% Assign the sender's email address.
% It can be an actual, real e-mail address,
% but it does not have to be an account that actually exists -
% you can make up one.
sendersEmail = 'me@mydomain.com';
recipientsEMail = 'somebody@Outlook.com';
% Set your email and SMTP server address in MATLAB.
setpref('Internet', 'SMTP_Server', mySMTP)
setpref('Internet', 'E_mail', sendersEmail)
setpref('Internet','SMTP_Username', myUserName);
setpref('Internet','SMTP_Password', myPassword);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
% Here's where we actually send out the e-mail with the file attached.
sendmail(recipientsEMail, subjectLine, messageBody, attachedFullFileName)

Sign in to comment.

More Answers (1)

You can use sendmail, though you will need to save the image to a temporary file (attachments can only be files).

4 Comments

so i can't send a picture using matlab gui to an email?
You can but it needs to be in a file saved to disk rather than directly as a variable right out of the script. If you were to put an image variable into the body of the message it would look like gibberish, so it has to be an attachment. Attachments have to be files saved on your disk.
okay how can i send an attachment to an email , "like what you said it has yo be an attachment"
what is the code for it?
thanks
Trying using a function like imwrite to create a image file on disk, then attached it to the email as one of the parameters to sendmail.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!