Matlab Email (sendmail) : subject and body input dialog error

3 views (last 30 days)
Hello!
The input dialog box 'inputdlg' for both the subject and body prevents the 'sendmail' function from processing the inputs. Although the normal 'input' function allows for the subject and body to be properly processed, the issue is that a body of text will often require formatting and pressing enter in the command prompt will cause immediate processing.
Any help is appreciated,
Alex
query = inputdlg('Which webmail service will you be using? ', 'WebMail Service', [1 50]);
if strcmp(query,'gmail') || strcmp(query,'Gmail')
myaddress = strcat(inputdlg('Please enter your gmail username: ',...
'Email Address', [1 50]),'@gmail.com'); mysmtp = 'smtp.gmail.com';
elseif strcmp(query,'yahoo') || strcmp(query,'yahoomail')
myaddress = strcat(inputdlg('Please enter your yahoomail username: ',...
'Email Address', [1 50]),'@yahoo.com'); mysmtp = 'smtp.mail.yahoo.com';
else
myaddress = inputdlg('Please enter your FULL email address: ',...
'Email Address', [1 50]); mysmtp = inputdlg('Please enter your webmail smtp server address: ');
end
mypassword = inputdlg('Please enter the password: ', 'Password', [1 50]);
setpref('Internet','E_mail',myaddress);
setpref('Internet','SMTP_Server',mysmtp);
setpref('Internet','SMTP_Username',myaddress);
setpref('Internet','SMTP_Password',mypassword);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', ...
'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
target = inputdlg('Please enter FULL recipient email address: ', 'Recipient', [1 50]);
subject = inputdlg('Please enter a subject header ', 'Subject', [1 50]);
body = inputdlg('Please enter body text ', 'Body', [1 50]);
sendmail(target, subject, body);

Answers (1)

Image Analyst
Image Analyst on 24 Jul 2014
You can make a GUI with a multi-line edit text box and an OK or "Accept" or "Done" button. However I don't think you can format the text (font style, color, size, weight, italics, etc.).
  1 Comment
Alex George
Alex George on 24 Jul 2014
I apologize if the phrasing of my question was confusing, but my inquiry doesn't have to do with text formatting. Rather I am asking why the sendmail function (last line) does not process the dialog box-inputted "subject" and "body" strings (second and third to last lines)?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!