我想使用Matlab
GUI发送电子邮件。我将发送按钮编码为:
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mail = 'paddydisease@gmail.com';
password = '123445';
setpref ('Internet','Email',mail);
setpref ('Internet','SMTP_Server','smtp.gmail.com');
setpref ('Internet','SMTP_Username',mail);
setpref ('Internet','SMTP_Password',password);
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');
a = get(handles.edit1,'String');
b = get (handles.edit1,'String');
sendmail(a,'Test from MATLAB',b);
set(handles.edite1,'String','');
set(handles.edite2,'String','');
msgbox('Disease deatails Successfully Send')
但错误信息如下所示:
Error using sendmail (line 67)
Could not determine FROM address. You can set one like this:
setpref('Internet','E_mail','username@example.com');
Error in gui>pushbutton3_Callback (line 171)
sendmail(a,'Test from MATLAB',b);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in gui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)gui('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback