email sending instance:
Private sub Sendmail () </P> <p> dim mailsender as smtpclient 'email sending object instance <br/> dim mailmsg as mailmessage 'email information instance <br/> dim mailfile as attachment' attachment instance <br/> dim mailaddressfrom as string 'sender's email address <br/> dim mailpassword as string 'email password <br/> dim mailtitle as string' email title <br/> dim mailcontent string 'mail content <br/> dim mailaddressto as string' recipient's email address </P> <p> 'variable initialization <br/> mailaddressfrom = "From@163.com"' sender's email address <br/> mailpassword = "password" 'mailbox password <br/> mailtitle = "title" 'mail title <br/> mailcontent = "test"' mail content <br/> mailaddressto = "To@163.com" 'recipient email address </P> <p> try </P> <p> 'initialize the mail Information instance <br/> mailmsg = new mailmessage (_ <br /> New mailaddress (mailaddressfrom ), _ <br/> New mailaddress (mailaddressto) </P> <p> 'sets the mail title and content. <br/> mailmsg. subject = mailtitle <br/> mailmsg. body = mailcontent </P> <p> 'add an attachment <br/> mailfile = new attachment ("C:/boot. ini ") <br/> mailmsg. attachments. add (mailfile) </P> <p> 'initialize the email sending object instance <br/> mailsender = new smtpclient () </P> <p> 'set email parameters <br/> mailsender. port = 25' port <br/> mailsender. host = "smtp.163.com" 'smtp address <br/> mailsender. deliverymethod = smtpdeliverymethod. network 'sending method <br/> mailsender. credentials = _ <br/> new system. net. networkcredential (mailaddressfrom, mailpassword) 'user credential </P> <p>' send an email <br/> mailsender. send (mailmsg) </P> <p> MessageBox. show ("sent successfully. ") </P> <p> catch ex as exception </P> <p> msgbox (" error: "& vbcrlf & Ex. message) </P> <p> end try </P> <p> end sub <br/>
===
If the above content is useful to you, please reply to any point. Thank you!