资源描述:
《如何使用matlab发送html格式邮件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Matlab发送html格式邮件Matlab是非常优秀的数据分析软件,具有很多优秀的功能,比如发送邮件。但是matlab自带的sendmail不支持html方式发送邮件正文,有时候非常不方便。查询可知matlab的sendmail和java的javax.mailpackage有密切关系,可以通过修改原函数的部分参数,扩展后就可以发送带html格式正文的邮件了。先截图看下效果:修改的部分为:将原函数的119-130行改为下图所示:修改前修改后此外将maxLineLength=75;改为maxLineLength=inf;然后再按照原来函数的用法发送邮件就可以了。做法来源于:
2、http://undocumentedmatlab.com/blog/sending-html-emails-from-matlab。附件自带本人修改后的函数,可以复制下到matlab创建函数直接使用。注意:使用sendmail函数发送邮件之前需要先进行设置,具体可以参考matlab说明。functionsendmail(to,subject,theMessage,attachments)%SENDMAILSende-mail.%SENDMAIL(TO,SUBJECT,MESSAGE,ATTACHMENTS)sendsane-mail.TOiseithera%charac
3、tervectorspecifyingasingleaddress,oracellarrayofcharactervector%addresses.SUBJECTisacharactervector.MESSAGEiseitheracharactervectororacell%arrayofcharactervectors.Ifitisacharactervector,thetextwill%automaticallywrapat75characters.Ifitisacellarray,itwon'twrap,but%eachcellstartsanewline.Ine
4、ithercase,usechar(10)toexplicitlyspecify%anewline.ATTACHMENTSisacharactervectororacellarrayofcharacter%vectorslistingfilestosendalongwiththemessage.OnlyTOandSUBJECTare%required.%%SENDMAILreliesontwopreferences,"Internet:SMTP_Server",yourmailserver,and%"Internet:E_mail",youre-mailaddress.U
5、seSETPREFtosetthesebeforeusing%SENDMAIL.Theeasiestwaystoidentifyyouroutgoingmailserveristolookat%thepreferencesofanothere-mailapplicationorconsultyouradministrator.If%youcannotfindoutyourserver'sname,settingittojust'mail'mightwork.If%youdonotsetthesepreferencesSENDMAILwilltrytodetermineth
6、em%automaticallybyreadingenvironmentvariablesandtheWindowsregistry.%%Example:%setpref('Internet','SMTP_Server','mail.example.com');%setpref('Internet','E_mail','matt@example.com');%sendmail('user@example.com','Calculationcomplete.')%sendmail({'matt@example.com','peter@example.com'},'You''
7、recool!',...%'Seetheattachedfilesformoreinfo.',{'attach1.m','d:attach2.doc'});%sendmail('user@example.com','Addingadditionalbreaks',['one'10'two']);%sendmail('user@example.com','Specifyingexactlines',{'one','two'});%%SeealsoWEB,FTP.%Copyright1984-2016TheMathWorks,I