Batch in the backgroundProgramTo send an email with an image, try the attachment method, and find that it is not ideal, it is easy to cause security risks.
This is also not detailed on msdn and the network. Here I will give a detailed introduction to this method. Please refer to the following function. You can modify it to suit your own program:
Private Sub sendremindmail () Sub Sendremindmail ( Byval Strto As String , Byval Strtoname As String , Byval Blnsendtolnemgr As Boolean )
Dim Objmailmessage As New Mailmessage
Dim Objsmtpclient As New Smtpclient
Dim Objaltview As Alternateview
Dim Objlnksrc As Invalid Resource
Dim Sb As New Stringbuilder
Dim Strfrom, strfromname As String
Strfrom = Configurationmanager. receivettings ( " Sender " ) ' Read the configuration information in the app. config file.
Strfromname = Configurationmanager. receivettings ( " Sendername " )
Strto = " LazzyTiger@Sohu.com "
Strtoname = " Lazzy Tiger "
Objmailmessage. From = New Mailaddress (strfrom, strfromname)
Objmailmessage. to. Add ( New Mailaddress (strto, strtoname ))
Objmailmessage. Subject = " Birthday Greeting "
If Blnsendtolnemgr = True Then
SB. append ( " <P style = 'font-size: 10pt; font-family: century Gothic, Arial; '> " )
SB. append ( " Please note that your staff listed below does not have email access. kindly ensure that a printed copy of this e-birthday card (preferably in color) reaches your staff within a week's time. " )
SB. append ( " <Br> & nbsp;-& nbsp; " & Strstaffname & " & Nbsp ;( " & Strstaffdeptdescr & " ) </P> " )
End If
SB. append ( " <P style = 'font-size: 10pt; font-family: century Gothic, Arial; '> dear colleague, </P> " )
SB. append ( " <P style = 'font-size: 10pt; font-family: century Gothic, Arial; '> </P> " )
SB. append ( " <P style = 'font-size: 10pt; font-family: century Gothic, Arial; '> Best wishes, <br> " )
SB. append ( " Your SingTel family </P> " )
Objaltview = alternateview. createalternateviewfromstring (sb. tostring, encoding. ASCII, "text/html ")
Objlnksrc = new temporary resource (application. startuppath & "/birthday.jpg", "image/jpg ")
Objlnksrc. contentid = "image01"
Objaltview. shareresources. Add (objlnksrc)
Objmailmessage. alternateviews. Add (objaltview)
Objsmtpclient. Host = Configurationmanager. receivettings ( " Smtpserver " )
Objsmtpclient. Send (objmailmessage)
End sub
Note the blue partCodeHere is the key. Of course, you can also connect to the resource files embedded in the program. It's not hard for you to find out.