Matlab Email (sendmail) : subject and body input dialog error
4 views (last 30 days)
Show older comments
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);
0 Comments
Answers (1)
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.).
See Also
Categories
Find more on Web Services in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!