使用Matlab GUI发送电子邮件

时间:2016-04-04 13:23:31

标签: matlab

我想使用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

0 个答案:

没有答案