Advertisement
Guest User

asfasf

a guest
Feb 10th, 2018
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 258.83 KB | None | 0 0
  1. ' ***********************************************************************
  2. ' Author : Elektro
  3. ' Modified : 12-December-2017
  4. ' ***********************************************************************
  5.  
  6. #Region " Public Members Summary "
  7.  
  8. #Region " Methods "
  9.  
  10. ' SendGMailText(String, String, String, String, String)
  11. ' SendGMailText(String, String, String, String, String, Attachment())
  12. ' SendGMailText(String, String, String, String, String, Collection(Of Attachment))
  13. ' SendGMailText(String, String, String, String, MailAddress)
  14. ' SendGMailText(String, String, String, String, MailAddress, Attachment())
  15. ' SendGMailText(String, String, String, String, MailAddress, Collection(Of Attachment))
  16. ' SendGMailText(String, String, String, String, String())
  17. ' SendGMailText(String, String, String, String, String(), Attachment())
  18. ' SendGMailText(String, String, String, String, String(), Collection(Of Attachment))
  19. ' SendGMailText(String, String, String, String, MailAddressCollection)
  20. ' SendGMailText(String, String, String, String, MailAddressCollection, Attachment())
  21. ' SendGMailText(String, String, String, String, MailAddressCollection, Collection(Of Attachment))
  22.  
  23. ' SendGMailText(NetworkCredential, String, String, String)
  24. ' SendGMailText(NetworkCredential, String, String, String, Attachment())
  25. ' SendGMailText(NetworkCredential, String, String, String, Collection(Of Attachment))
  26. ' SendGMailText(NetworkCredential, String, String, MailAddress)
  27. ' SendGMailText(NetworkCredential, String, String, MailAddress, Attachment())
  28. ' SendGMailText(NetworkCredential, String, String, MailAddress, Collection(Of Attachment))
  29. ' SendGMailText(NetworkCredential, String, String, String())
  30. ' SendGMailText(NetworkCredential, String, String, String(), Attachment())
  31. ' SendGMailText(NetworkCredential, String, String, String(), Collection(Of Attachment))
  32. ' SendGMailText(NetworkCredential, String, String, MailAddressCollection)
  33. ' SendGMailText(NetworkCredential, String, String, MailAddressCollection, Attachment())
  34. ' SendGMailText(NetworkCredential, String, String, MailAddressCollection, Collection(Of Attachment))
  35.  
  36. ' SendGMailHtml(String, String, String, String, String)
  37. ' SendGMailHtml(String, String, String, String, String, Attachment())
  38. ' SendGMailHtml(String, String, String, String, String, Collection(Of Attachment))
  39. ' SendGMailHtml(String, String, String, String, MailAddress)
  40. ' SendGMailHtml(String, String, String, String, MailAddress, Attachment())
  41. ' SendGMailHtml(String, String, String, String, MailAddress, Collection(Of Attachment))
  42. ' SendGMailHtml(String, String, String, String, String())
  43. ' SendGMailHtml(String, String, String, String, String(), Attachment())
  44. ' SendGMailHtml(String, String, String, String, String(), Collection(Of Attachment))
  45. ' SendGMailHtml(String, String, String, String, MailAddressCollection)
  46. ' SendGMailHtml(String, String, String, String, MailAddressCollection, Attachment())
  47. ' SendGMailHtml(String, String, String, String, MailAddressCollection, Collection(Of Attachment))
  48.  
  49. ' SendGMailHtml(NetworkCredential, String, String, String)
  50. ' SendGMailHtml(NetworkCredential, String, String, String, Attachment())
  51. ' SendGMailHtml(NetworkCredential, String, String, String, Collection(Of Attachment))
  52. ' SendGMailHtml(NetworkCredential, String, String, MailAddress)
  53. ' SendGMailHtml(NetworkCredential, String, String, MailAddress, Attachment())
  54. ' SendGMailHtml(NetworkCredential, String, String, MailAddress, Collection(Of Attachment))
  55. ' SendGMailHtml(NetworkCredential, String, String, String())
  56. ' SendGMailHtml(NetworkCredential, String, String, String(), Attachment())
  57. ' SendGMailHtml(NetworkCredential, String, String, String(), Collection(Of Attachment))
  58. ' SendGMailHtml(NetworkCredential, String, String, MailAddressCollection)
  59. ' SendGMailHtml(NetworkCredential, String, String, MailAddressCollection, Attachment())
  60. ' SendGMailHtml(NetworkCredential, String, String, MailAddressCollection, Collection(Of Attachment))
  61.  
  62. #End Region
  63.  
  64. #Region " Functions "
  65.  
  66. ' SendGMailAsyncText(String, String, String, String, String) As Task
  67. ' SendGMailAsyncText(String, String, String, String, String Attachment()) As Task
  68. ' SendGMailAsyncText(String, String, String, String, String, Collection(Of Attachment)) As Task
  69. ' SendGMailAsyncText(String, String, String, String, MailAddress) As Task
  70. ' SendGMailAsyncText(String, String, String, String, MailAddress Attachment()) As Task
  71. ' SendGMailAsyncText(String, String, String, String, MailAddress, Collection(Of Attachment)) As Task
  72. ' SendGMailAsyncText(String, String, String, String, String()) As Task
  73. ' SendGMailAsyncText(String, String, String, String, String() Attachment()) As Task
  74. ' SendGMailAsyncText(String, String, String, String, String(), Collection(Of Attachment)) As Task
  75. ' SendGMailAsyncText(String, String, String, String, MailAddressCollection) As Task
  76. ' SendGMailAsyncText(String, String, String, String, MailAddressCollection Attachment()) As Task
  77. ' SendGMailAsyncText(String, String, String, String, MailAddressCollection, Collection(Of Attachment)) As Task
  78.  
  79. ' SendGMailAsyncText(NetworkCredential, String, String, String) As Task
  80. ' SendGMailAsyncText(NetworkCredential, String, String, String Attachment()) As Task
  81. ' SendGMailAsyncText(NetworkCredential, String, String, String, Collection(Of Attachment)) As Task
  82. ' SendGMailAsyncText(NetworkCredential, String, String, MailAddress) As Task
  83. ' SendGMailAsyncText(NetworkCredential, String, String, MailAddress Attachment()) As Task
  84. ' SendGMailAsyncText(NetworkCredential, String, String, MailAddress, Collection(Of Attachment)) As Task
  85. ' SendGMailAsyncText(NetworkCredential, String, String, String()) As Task
  86. ' SendGMailAsyncText(NetworkCredential, String, String, String() Attachment()) As Task
  87. ' SendGMailAsyncText(NetworkCredential, String, String, String(), Collection(Of Attachment)) As Task
  88. ' SendGMailAsyncText(NetworkCredential, String, String, MailAddressCollection) As Task
  89. ' SendGMailAsyncText(NetworkCredential, String, String, MailAddressCollection Attachment()) As Task
  90. ' SendGMailAsyncText(NetworkCredential, String, String, MailAddressCollection, Collection(Of Attachment)) As Task
  91.  
  92. ' SendGMailAsyncHtml(String, String, String, String, String) As Task
  93. ' SendGMailAsyncHtml(String, String, String, String, String Attachment()) As Task
  94. ' SendGMailAsyncHtml(String, String, String, String, String, Collection(Of Attachment)) As Task
  95. ' SendGMailAsyncHtml(String, String, String, String, MailAddress) As Task
  96. ' SendGMailAsyncHtml(String, String, String, String, MailAddress Attachment()) As Task
  97. ' SendGMailAsyncHtml(String, String, String, String, MailAddress, Collection(Of Attachment)) As Task
  98. ' SendGMailAsyncHtml(String, String, String, String, String()) As Task
  99. ' SendGMailAsyncHtml(String, String, String, String, String() Attachment()) As Task
  100. ' SendGMailAsyncHtml(String, String, String, String, String(), Collection(Of Attachment)) As Task
  101. ' SendGMailAsyncHtml(String, String, String, String, MailAddressCollection) As Task
  102. ' SendGMailAsyncHtml(String, String, String, String, MailAddressCollection Attachment()) As Task
  103. ' SendGMailAsyncHtml(String, String, String, String, MailAddressCollection, Collection(Of Attachment)) As Task
  104.  
  105. ' SendGMailAsyncHtml(NetworkCredential, String, String, String) As Task
  106. ' SendGMailAsyncHtml(NetworkCredential, String, String, String Attachment()) As Task
  107. ' SendGMailAsyncHtml(NetworkCredential, String, String, String, Collection(Of Attachment)) As Task
  108. ' SendGMailAsyncHtml(NetworkCredential, String, String, MailAddress) As Task
  109. ' SendGMailAsyncHtml(NetworkCredential, String, String, MailAddress Attachment()) As Task
  110. ' SendGMailAsyncHtml(NetworkCredential, String, String, MailAddress, Collection(Of Attachment)) As Task
  111. ' SendGMailAsyncHtml(NetworkCredential, String, String, String()) As Task
  112. ' SendGMailAsyncHtml(NetworkCredential, String, String, String() Attachment()) As Task
  113. ' SendGMailAsyncHtml(NetworkCredential, String, String, String(), Collection(Of Attachment)) As Task
  114. ' SendGMailAsyncHtml(NetworkCredential, String, String, MailAddressCollection) As Task
  115. ' SendGMailAsyncHtml(NetworkCredential, String, String, MailAddressCollection Attachment()) As Task
  116. ' SendGMailAsyncHtml(NetworkCredential, String, String, MailAddressCollection, Collection(Of Attachment)) As Task
  117.  
  118. #End Region
  119.  
  120. #End Region
  121.  
  122. #Region " Option Statements "
  123.  
  124. Option Strict On
  125. Option Explicit On
  126. Option Infer Off
  127.  
  128. #End Region
  129.  
  130. #Region " Imports "
  131.  
  132. Imports System.Collections.ObjectModel
  133. Imports System.Net
  134. Imports System.Net.Mail
  135. Imports System.Threading.Tasks
  136.  
  137. 'Imports ElektroKit.Core.Types
  138.  
  139. #End Region
  140.  
  141. #Region " Mail Util "
  142.  
  143. Namespace NET.Tools
  144.  
  145. Partial Public NotInheritable Class MailUtil ': Inherits AestheticObject
  146.  
  147. #Region " Public Methods "
  148.  
  149. #Region " Text Body "
  150.  
  151. ''' ----------------------------------------------------------------------------------------------------
  152. ''' <summary>
  153. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  154. ''' <para></para>
  155. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  156. ''' <para></para>
  157. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  158. ''' </summary>
  159. ''' ----------------------------------------------------------------------------------------------------
  160. ''' <example> This is a code example.
  161. ''' <code>
  162. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Address@Server.com")
  163. ''' </code>
  164. ''' </example>
  165. ''' ----------------------------------------------------------------------------------------------------
  166. ''' <remarks>
  167. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  168. ''' <para></para>
  169. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  170. ''' </remarks>
  171. ''' ----------------------------------------------------------------------------------------------------
  172. ''' <param name="username">
  173. ''' The username of the Gmail account.
  174. ''' </param>
  175. '''
  176. ''' <param name="password">
  177. ''' The password of the Gmail account.
  178. ''' </param>
  179. '''
  180. ''' <param name="subject">
  181. ''' The mail subject.
  182. ''' </param>
  183. '''
  184. ''' <param name="body">
  185. ''' The mail body.
  186. ''' </param>
  187. '''
  188. ''' <param name="address">
  189. ''' The target address that will receive our sent mail.
  190. ''' </param>
  191. ''' ----------------------------------------------------------------------------------------------------
  192. <DebuggerStepThrough>
  193. Public Shared Sub SendGMailText(ByVal username As String,
  194. ByVal password As String,
  195. ByVal subject As String,
  196. ByVal body As String,
  197. ByVal address As String)
  198.  
  199. MailUtil.SendGMailText(username, password, subject, body, {address})
  200.  
  201. End Sub
  202.  
  203. ''' ----------------------------------------------------------------------------------------------------
  204. ''' <summary>
  205. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  206. ''' <para></para>
  207. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  208. ''' <para></para>
  209. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  210. ''' </summary>
  211. ''' ----------------------------------------------------------------------------------------------------
  212. ''' <example> This is a code example.
  213. ''' <code>
  214. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  215. ''' </code>
  216. ''' </example>
  217. ''' ----------------------------------------------------------------------------------------------------
  218. ''' <remarks>
  219. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  220. ''' <para></para>
  221. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  222. ''' </remarks>
  223. ''' ----------------------------------------------------------------------------------------------------
  224. ''' <param name="username">
  225. ''' The username of the Gmail account.
  226. ''' </param>
  227. '''
  228. ''' <param name="password">
  229. ''' The password of the Gmail account.
  230. ''' </param>
  231. '''
  232. ''' <param name="subject">
  233. ''' The mail subject.
  234. ''' </param>
  235. '''
  236. ''' <param name="body">
  237. ''' The mail body.
  238. ''' </param>
  239. '''
  240. ''' <param name="address">
  241. ''' The target address that will receive our sent mail.
  242. ''' </param>
  243. '''
  244. ''' <param name="attachments">
  245. ''' The file(s) to attach in this e-mail.
  246. ''' </param>
  247. ''' ----------------------------------------------------------------------------------------------------
  248. <DebuggerStepThrough>
  249. Public Shared Sub SendGMailText(ByVal username As String,
  250. ByVal password As String,
  251. ByVal subject As String,
  252. ByVal body As String,
  253. ByVal address As String,
  254. ParamArray attachments As Attachment())
  255.  
  256. MailUtil.SendGMailText(username, password, subject, body, {address}, attachments)
  257.  
  258. End Sub
  259.  
  260. ''' ----------------------------------------------------------------------------------------------------
  261. ''' <summary>
  262. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  263. ''' <para></para>
  264. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  265. ''' <para></para>
  266. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  267. ''' </summary>
  268. ''' ----------------------------------------------------------------------------------------------------
  269. ''' <example> This is a code example.
  270. ''' <code>
  271. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  272. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", attachments)
  273. ''' </code>
  274. ''' </example>
  275. ''' ----------------------------------------------------------------------------------------------------
  276. ''' <remarks>
  277. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  278. ''' <para></para>
  279. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  280. ''' </remarks>
  281. ''' ----------------------------------------------------------------------------------------------------
  282. ''' <param name="username">
  283. ''' The username of the Gmail account.
  284. ''' </param>
  285. '''
  286. ''' <param name="password">
  287. ''' The password of the Gmail account.
  288. ''' </param>
  289. '''
  290. ''' <param name="subject">
  291. ''' The mail subject.
  292. ''' </param>
  293. '''
  294. ''' <param name="body">
  295. ''' The mail body.
  296. ''' </param>
  297. '''
  298. ''' <param name="address">
  299. ''' The target address that will receive our sent mail.
  300. ''' </param>
  301. '''
  302. ''' <param name="attachments">
  303. ''' The file(s) to attach in this e-mail.
  304. ''' </param>
  305. ''' ----------------------------------------------------------------------------------------------------
  306. <DebuggerStepThrough>
  307. Public Shared Sub SendGMailText(ByVal username As String,
  308. ByVal password As String,
  309. ByVal subject As String,
  310. ByVal body As String,
  311. ByVal address As String,
  312. ByVal attachments As Collection(Of Attachment))
  313.  
  314. MailUtil.SendGMailText(username, password, subject, body, {address}, attachments)
  315.  
  316. End Sub
  317.  
  318. ''' ----------------------------------------------------------------------------------------------------
  319. ''' <summary>
  320. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  321. ''' <para></para>
  322. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  323. ''' <para></para>
  324. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  325. ''' </summary>
  326. ''' ----------------------------------------------------------------------------------------------------
  327. ''' <example> This is a code example.
  328. ''' <code>
  329. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  330. ''' </code>
  331. ''' </example>
  332. ''' ----------------------------------------------------------------------------------------------------
  333. ''' <remarks>
  334. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  335. ''' <para></para>
  336. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  337. ''' </remarks>
  338. ''' ----------------------------------------------------------------------------------------------------
  339. ''' <param name="username">
  340. ''' The username of the Gmail account.
  341. ''' </param>
  342. '''
  343. ''' <param name="password">
  344. ''' The password of the Gmail account.
  345. ''' </param>
  346. '''
  347. ''' <param name="subject">
  348. ''' The mail subject.
  349. ''' </param>
  350. '''
  351. ''' <param name="body">
  352. ''' The mail body.
  353. ''' </param>
  354. '''
  355. ''' <param name="address">
  356. ''' The target address that will receive our sent mail.
  357. ''' </param>
  358. ''' ----------------------------------------------------------------------------------------------------
  359. <DebuggerStepThrough>
  360. Public Shared Sub SendGMailText(ByVal username As String,
  361. ByVal password As String,
  362. ByVal subject As String,
  363. ByVal body As String,
  364. ByVal address As MailAddress)
  365.  
  366. MailUtil.SendGMailText(username, password, subject, body, {address.Address})
  367.  
  368. End Sub
  369.  
  370. ''' ----------------------------------------------------------------------------------------------------
  371. ''' <summary>
  372. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  373. ''' <para></para>
  374. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  375. ''' <para></para>
  376. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  377. ''' </summary>
  378. ''' ----------------------------------------------------------------------------------------------------
  379. ''' <example> This is a code example.
  380. ''' <code>
  381. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  382. ''' </code>
  383. ''' </example>
  384. ''' ----------------------------------------------------------------------------------------------------
  385. ''' <remarks>
  386. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  387. ''' <para></para>
  388. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  389. ''' </remarks>
  390. ''' ----------------------------------------------------------------------------------------------------
  391. ''' <param name="username">
  392. ''' The username of the Gmail account.
  393. ''' </param>
  394. '''
  395. ''' <param name="password">
  396. ''' The password of the Gmail account.
  397. ''' </param>
  398. '''
  399. ''' <param name="subject">
  400. ''' The mail subject.
  401. ''' </param>
  402. '''
  403. ''' <param name="body">
  404. ''' The mail body.
  405. ''' </param>
  406. '''
  407. ''' <param name="address">
  408. ''' The target address that will receive our sent mail.
  409. ''' </param>
  410. '''
  411. ''' <param name="attachments">
  412. ''' The file(s) to attach in this e-mail.
  413. ''' </param>
  414. ''' ----------------------------------------------------------------------------------------------------
  415. <DebuggerStepThrough>
  416. Public Shared Sub SendGMailText(ByVal username As String,
  417. ByVal password As String,
  418. ByVal subject As String,
  419. ByVal body As String,
  420. ByVal address As MailAddress,
  421. ParamArray attachments As Attachment())
  422.  
  423. MailUtil.SendGMailText(username, password, subject, body, {address.Address}, attachments)
  424.  
  425. End Sub
  426.  
  427. ''' ----------------------------------------------------------------------------------------------------
  428. ''' <summary>
  429. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  430. ''' <para></para>
  431. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  432. ''' <para></para>
  433. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  434. ''' </summary>
  435. ''' ----------------------------------------------------------------------------------------------------
  436. ''' <example> This is a code example.
  437. ''' <code>
  438. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  439. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  440. ''' </code>
  441. ''' </example>
  442. ''' ----------------------------------------------------------------------------------------------------
  443. ''' <remarks>
  444. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  445. ''' <para></para>
  446. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  447. ''' </remarks>
  448. ''' ----------------------------------------------------------------------------------------------------
  449. ''' <param name="username">
  450. ''' The username of the Gmail account.
  451. ''' </param>
  452. '''
  453. ''' <param name="password">
  454. ''' The password of the Gmail account.
  455. ''' </param>
  456. '''
  457. ''' <param name="subject">
  458. ''' The mail subject.
  459. ''' </param>
  460. '''
  461. ''' <param name="body">
  462. ''' The mail body.
  463. ''' </param>
  464. '''
  465. ''' <param name="address">
  466. ''' The target address that will receive our sent mail.
  467. ''' </param>
  468. '''
  469. ''' <param name="attachments">
  470. ''' The file(s) to attach in this e-mail.
  471. ''' </param>
  472. ''' ----------------------------------------------------------------------------------------------------
  473. <DebuggerStepThrough>
  474. Public Shared Sub SendGMailText(ByVal username As String,
  475. ByVal password As String,
  476. ByVal subject As String,
  477. ByVal body As String,
  478. ByVal address As MailAddress,
  479. ByVal attachments As Collection(Of Attachment))
  480.  
  481. MailUtil.SendGMailText(username, password, subject, body, {address.Address}, attachments)
  482.  
  483. End Sub
  484.  
  485. ''' ----------------------------------------------------------------------------------------------------
  486. ''' <summary>
  487. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  488. ''' <para></para>
  489. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  490. ''' <para></para>
  491. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  492. ''' </summary>
  493. ''' ----------------------------------------------------------------------------------------------------
  494. ''' <example> This is a code example.
  495. ''' <code>
  496. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  497. ''' </code>
  498. ''' </example>
  499. ''' ----------------------------------------------------------------------------------------------------
  500. ''' <remarks>
  501. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  502. ''' <para></para>
  503. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  504. ''' </remarks>
  505. ''' ----------------------------------------------------------------------------------------------------
  506. ''' <param name="username">
  507. ''' The username of the Gmail account.
  508. ''' </param>
  509. '''
  510. ''' <param name="password">
  511. ''' The password of the Gmail account.
  512. ''' </param>
  513. '''
  514. ''' <param name="subject">
  515. ''' The mail subject.
  516. ''' </param>
  517. '''
  518. ''' <param name="body">
  519. ''' The mail body.
  520. ''' </param>
  521. '''
  522. ''' <param name="addresses">
  523. ''' The target addresses that will receive our sent mail.
  524. ''' </param>
  525. ''' ----------------------------------------------------------------------------------------------------
  526. <DebuggerStepThrough>
  527. Public Shared Sub SendGMailText(ByVal username As String,
  528. ByVal password As String,
  529. ByVal subject As String,
  530. ByVal body As String,
  531. ByVal addresses As String())
  532.  
  533. Dim addressCollection As New MailAddressCollection
  534. For Each address As String In addresses
  535. addressCollection.Add(New MailAddress(address))
  536. Next address
  537.  
  538. MailUtil.SendGMailText(username, password, subject, body, addressCollection, attachments:=Nothing)
  539.  
  540. End Sub
  541.  
  542. ''' ----------------------------------------------------------------------------------------------------
  543. ''' <summary>
  544. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  545. ''' <para></para>
  546. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  547. ''' <para></para>
  548. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  549. ''' </summary>
  550. ''' ----------------------------------------------------------------------------------------------------
  551. ''' <example> This is a code example.
  552. ''' <code>
  553. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  554. ''' </code>
  555. ''' </example>
  556. ''' ----------------------------------------------------------------------------------------------------
  557. ''' <remarks>
  558. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  559. ''' <para></para>
  560. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  561. ''' </remarks>
  562. ''' ----------------------------------------------------------------------------------------------------
  563. ''' <param name="username">
  564. ''' The username of the Gmail account.
  565. ''' </param>
  566. '''
  567. ''' <param name="password">
  568. ''' The password of the Gmail account.
  569. ''' </param>
  570. '''
  571. ''' <param name="subject">
  572. ''' The mail subject.
  573. ''' </param>
  574. '''
  575. ''' <param name="body">
  576. ''' The mail body.
  577. ''' </param>
  578. '''
  579. ''' <param name="addresses">
  580. ''' The target addresses that will receive our sent mail.
  581. ''' </param>
  582. '''
  583. ''' <param name="attachments">
  584. ''' The file(s) to attach in this e-mail.
  585. ''' </param>
  586. ''' ----------------------------------------------------------------------------------------------------
  587. <DebuggerStepThrough>
  588. Public Shared Sub SendGMailText(ByVal username As String,
  589. ByVal password As String,
  590. ByVal subject As String,
  591. ByVal body As String,
  592. ByVal addresses As String(),
  593. ParamArray attachments As Attachment())
  594.  
  595. Dim addressCollection As New MailAddressCollection
  596. For Each address As String In addresses
  597. addressCollection.Add(New MailAddress(address))
  598. Next address
  599.  
  600. MailUtil.SendGMailText(username, password, subject, body, addressCollection, attachments)
  601.  
  602. End Sub
  603.  
  604. ''' ----------------------------------------------------------------------------------------------------
  605. ''' <summary>
  606. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  607. ''' <para></para>
  608. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  609. ''' <para></para>
  610. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  611. ''' </summary>
  612. ''' ----------------------------------------------------------------------------------------------------
  613. ''' <example> This is a code example.
  614. ''' <code>
  615. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  616. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  617. ''' </code>
  618. ''' </example>
  619. ''' ----------------------------------------------------------------------------------------------------
  620. ''' <remarks>
  621. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  622. ''' <para></para>
  623. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  624. ''' </remarks>
  625. ''' ----------------------------------------------------------------------------------------------------
  626. ''' <param name="username">
  627. ''' The username of the Gmail account.
  628. ''' </param>
  629. '''
  630. ''' <param name="password">
  631. ''' The password of the Gmail account.
  632. ''' </param>
  633. '''
  634. ''' <param name="subject">
  635. ''' The mail subject.
  636. ''' </param>
  637. '''
  638. ''' <param name="body">
  639. ''' The mail body.
  640. ''' </param>
  641. '''
  642. ''' <param name="addresses">
  643. ''' The target addresses that will receive our sent mail.
  644. ''' </param>
  645. '''
  646. ''' <param name="attachments">
  647. ''' The file(s) to attach in this e-mail.
  648. ''' </param>
  649. ''' ----------------------------------------------------------------------------------------------------
  650. <DebuggerStepThrough>
  651. Public Shared Sub SendGMailText(ByVal username As String,
  652. ByVal password As String,
  653. ByVal subject As String,
  654. ByVal body As String,
  655. ByVal addresses As String(),
  656. ByVal attachments As Collection(Of Attachment))
  657.  
  658. Dim addressCollection As New MailAddressCollection
  659. For Each address As String In addresses
  660. addressCollection.Add(New MailAddress(address))
  661. Next address
  662.  
  663. MailUtil.SendGMailText(username, password, subject, body, addressCollection, attachments)
  664.  
  665. End Sub
  666.  
  667. ''' ----------------------------------------------------------------------------------------------------
  668. ''' <summary>
  669. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  670. ''' <para></para>
  671. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  672. ''' <para></para>
  673. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  674. ''' </summary>
  675. ''' ----------------------------------------------------------------------------------------------------
  676. ''' <example> This is a code example.
  677. ''' <code>
  678. ''' Dim addressCollection As New MailAddressCollection
  679. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  680. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  681. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection)
  682. ''' </code>
  683. ''' </example>
  684. ''' ----------------------------------------------------------------------------------------------------
  685. ''' <remarks>
  686. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  687. ''' <para></para>
  688. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  689. ''' </remarks>
  690. ''' ----------------------------------------------------------------------------------------------------
  691. ''' <param name="username">
  692. ''' The username of the Gmail account.
  693. ''' </param>
  694. '''
  695. ''' <param name="password">
  696. ''' The password of the Gmail account.
  697. ''' </param>
  698. '''
  699. ''' <param name="subject">
  700. ''' The mail subject.
  701. ''' </param>
  702. '''
  703. ''' <param name="body">
  704. ''' The mail body.
  705. ''' </param>
  706. '''
  707. ''' <param name="addresses">
  708. ''' The target addresses that will receive our sent mail.
  709. ''' </param>
  710. ''' ----------------------------------------------------------------------------------------------------
  711. <DebuggerStepThrough>
  712. Public Shared Sub SendGMailText(ByVal username As String,
  713. ByVal password As String,
  714. ByVal subject As String,
  715. ByVal body As String,
  716. ByVal addresses As MailAddressCollection)
  717.  
  718. MailUtil.SendGMailText(username, password, subject, body, addresses, attachments:=Nothing)
  719.  
  720. End Sub
  721.  
  722. ''' ----------------------------------------------------------------------------------------------------
  723. ''' <summary>
  724. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  725. ''' <para></para>
  726. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  727. ''' <para></para>
  728. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  729. ''' </summary>
  730. ''' ----------------------------------------------------------------------------------------------------
  731. ''' <example> This is a code example.
  732. ''' <code>
  733. ''' Dim addressCollection As New MailAddressCollection
  734. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  735. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  736. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  737. ''' </code>
  738. ''' </example>
  739. ''' ----------------------------------------------------------------------------------------------------
  740. ''' <remarks>
  741. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  742. ''' <para></para>
  743. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  744. ''' </remarks>
  745. ''' ----------------------------------------------------------------------------------------------------
  746. ''' <param name="username">
  747. ''' The username of the Gmail account.
  748. ''' </param>
  749. '''
  750. ''' <param name="password">
  751. ''' The password of the Gmail account.
  752. ''' </param>
  753. '''
  754. ''' <param name="subject">
  755. ''' The mail subject.
  756. ''' </param>
  757. '''
  758. ''' <param name="body">
  759. ''' The mail body.
  760. ''' </param>
  761. '''
  762. ''' <param name="addresses">
  763. ''' The target addresses that will receive our sent mail.
  764. ''' </param>
  765. '''
  766. ''' <param name="attachments">
  767. ''' The file(s) to attach in this e-mail.
  768. ''' </param>
  769. ''' ----------------------------------------------------------------------------------------------------
  770. <DebuggerStepThrough>
  771. Public Shared Sub SendGMailText(ByVal username As String,
  772. ByVal password As String,
  773. ByVal subject As String,
  774. ByVal body As String,
  775. ByVal addresses As MailAddressCollection,
  776. ParamArray attachments As Attachment())
  777.  
  778. Dim attachCol As New Collection(Of Attachment)
  779. For Each attachment As Attachment In attachments
  780. attachCol.Add(attachment)
  781. Next attachment
  782.  
  783. MailUtil.SendGMailText(username, password, subject, body, addresses, attachCol)
  784.  
  785. End Sub
  786.  
  787. ''' ----------------------------------------------------------------------------------------------------
  788. ''' <summary>
  789. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  790. ''' <para></para>
  791. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  792. ''' <para></para>
  793. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  794. ''' </summary>
  795. ''' ----------------------------------------------------------------------------------------------------
  796. ''' <example> This is a code example.
  797. ''' <code>
  798. ''' Dim addressCollection As New MailAddressCollection
  799. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  800. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  801. '''
  802. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  803. '''
  804. ''' SendGMailText("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection, attachments)
  805. ''' </code>
  806. ''' </example>
  807. ''' ----------------------------------------------------------------------------------------------------
  808. ''' <remarks>
  809. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  810. ''' <para></para>
  811. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  812. ''' </remarks>
  813. ''' ----------------------------------------------------------------------------------------------------
  814. ''' <param name="username">
  815. ''' The username of the Gmail account.
  816. ''' </param>
  817. '''
  818. ''' <param name="password">
  819. ''' The password of the Gmail account.
  820. ''' </param>
  821. '''
  822. ''' <param name="subject">
  823. ''' The mail subject.
  824. ''' </param>
  825. '''
  826. ''' <param name="body">
  827. ''' The mail body.
  828. ''' </param>
  829. '''
  830. ''' <param name="addresses">
  831. ''' The target addresses that will receive our sent mail.
  832. ''' </param>
  833. '''
  834. ''' <param name="attachments">
  835. ''' The file(s) to attach in this e-mail.
  836. ''' </param>
  837. ''' ----------------------------------------------------------------------------------------------------
  838. <DebuggerStepThrough>
  839. Public Shared Sub SendGMailText(ByVal username As String,
  840. ByVal password As String,
  841. ByVal subject As String,
  842. ByVal body As String,
  843. ByVal addresses As MailAddressCollection,
  844. ByVal attachments As Collection(Of Attachment))
  845.  
  846. MailUtil.SendGMail(username, password, subject, body, addresses, attachments, isBodyHtml:=False)
  847.  
  848. End Sub
  849.  
  850. ''' ----------------------------------------------------------------------------------------------------
  851. ''' <summary>
  852. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  853. ''' <para></para>
  854. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  855. ''' <para></para>
  856. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  857. ''' </summary>
  858. ''' ----------------------------------------------------------------------------------------------------
  859. ''' <example> This is a code example.
  860. ''' <code>
  861. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  862. ''' SendGMailText(credential, "Email Subject", "Message Body", "Address@Server.com")
  863. ''' </code>
  864. ''' </example>
  865. ''' ----------------------------------------------------------------------------------------------------
  866. ''' <remarks>
  867. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  868. ''' <para></para>
  869. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  870. ''' </remarks>
  871. ''' ----------------------------------------------------------------------------------------------------
  872. ''' <param name="credential">
  873. ''' The credential containing the username and password for the Gmail account.
  874. ''' </param>
  875. '''
  876. ''' <param name="subject">
  877. ''' The mail subject.
  878. ''' </param>
  879. '''
  880. ''' <param name="body">
  881. ''' The mail body.
  882. ''' </param>
  883. '''
  884. ''' <param name="address">
  885. ''' The target address that will receive our sent mail.
  886. ''' </param>
  887. ''' ----------------------------------------------------------------------------------------------------
  888. <DebuggerStepThrough>
  889. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  890. ByVal subject As String,
  891. ByVal body As String,
  892. ByVal address As String)
  893.  
  894. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, {address})
  895.  
  896. End Sub
  897.  
  898. ''' ----------------------------------------------------------------------------------------------------
  899. ''' <summary>
  900. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  901. ''' <para></para>
  902. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  903. ''' <para></para>
  904. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  905. ''' </summary>
  906. ''' ----------------------------------------------------------------------------------------------------
  907. ''' <example> This is a code example.
  908. ''' <code>
  909. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  910. ''' SendGMailText(credential, "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  911. ''' </code>
  912. ''' </example>
  913. ''' ----------------------------------------------------------------------------------------------------
  914. ''' <remarks>
  915. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  916. ''' <para></para>
  917. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  918. ''' </remarks>
  919. ''' ----------------------------------------------------------------------------------------------------
  920. ''' <param name="credential">
  921. ''' The credential containing the username and password for the Gmail account.
  922. ''' </param>
  923. '''
  924. ''' <param name="subject">
  925. ''' The mail subject.
  926. ''' </param>
  927. '''
  928. ''' <param name="body">
  929. ''' The mail body.
  930. ''' </param>
  931. '''
  932. ''' <param name="address">
  933. ''' The target address that will receive our sent mail.
  934. ''' </param>
  935. '''
  936. ''' <param name="attachments">
  937. ''' The file(s) to attach in this e-mail.
  938. ''' </param>
  939. ''' ----------------------------------------------------------------------------------------------------
  940. <DebuggerStepThrough>
  941. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  942. ByVal subject As String,
  943. ByVal body As String,
  944. ByVal address As String,
  945. ParamArray attachments As Attachment())
  946.  
  947. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, {address}, attachments)
  948.  
  949. End Sub
  950.  
  951. ''' ----------------------------------------------------------------------------------------------------
  952. ''' <summary>
  953. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  954. ''' <para></para>
  955. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  956. ''' <para></para>
  957. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  958. ''' </summary>
  959. ''' ----------------------------------------------------------------------------------------------------
  960. ''' <example> This is a code example.
  961. ''' <code>
  962. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  963. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  964. ''' SendGMailText(credential, "Email Subject", "Message Body", "Address@Server.com", attachments)
  965. ''' </code>
  966. ''' </example>
  967. ''' ----------------------------------------------------------------------------------------------------
  968. ''' <remarks>
  969. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  970. ''' <para></para>
  971. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  972. ''' </remarks>
  973. ''' ----------------------------------------------------------------------------------------------------
  974. ''' <param name="credential">
  975. ''' The credential containing the username and password for the Gmail account.
  976. ''' </param>
  977. '''
  978. ''' <param name="subject">
  979. ''' The mail subject.
  980. ''' </param>
  981. '''
  982. ''' <param name="body">
  983. ''' The mail body.
  984. ''' </param>
  985. '''
  986. ''' <param name="address">
  987. ''' The target address that will receive our sent mail.
  988. ''' </param>
  989. '''
  990. ''' <param name="attachments">
  991. ''' The file(s) to attach in this e-mail.
  992. ''' </param>
  993. ''' ----------------------------------------------------------------------------------------------------
  994. <DebuggerStepThrough>
  995. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  996. ByVal subject As String,
  997. ByVal body As String,
  998. ByVal address As String,
  999. ByVal attachments As Collection(Of Attachment))
  1000.  
  1001. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, {address}, attachments)
  1002.  
  1003. End Sub
  1004.  
  1005. ''' ----------------------------------------------------------------------------------------------------
  1006. ''' <summary>
  1007. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1008. ''' <para></para>
  1009. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1010. ''' <para></para>
  1011. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1012. ''' </summary>
  1013. ''' ----------------------------------------------------------------------------------------------------
  1014. ''' <example> This is a code example.
  1015. ''' <code>
  1016. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1017. ''' SendGMailText(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  1018. ''' </code>
  1019. ''' </example>
  1020. ''' ----------------------------------------------------------------------------------------------------
  1021. ''' <remarks>
  1022. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1023. ''' <para></para>
  1024. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1025. ''' </remarks>
  1026. ''' ----------------------------------------------------------------------------------------------------
  1027. ''' <param name="credential">
  1028. ''' The credential containing the username and password for the Gmail account.
  1029. ''' </param>
  1030. '''
  1031. ''' <param name="subject">
  1032. ''' The mail subject.
  1033. ''' </param>
  1034. '''
  1035. ''' <param name="body">
  1036. ''' The mail body.
  1037. ''' </param>
  1038. '''
  1039. ''' <param name="address">
  1040. ''' The target address that will receive our sent mail.
  1041. ''' </param>
  1042. ''' ----------------------------------------------------------------------------------------------------
  1043. <DebuggerStepThrough>
  1044. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1045. ByVal subject As String,
  1046. ByVal body As String,
  1047. ByVal address As MailAddress)
  1048.  
  1049. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, {address.Address})
  1050.  
  1051. End Sub
  1052.  
  1053. ''' ----------------------------------------------------------------------------------------------------
  1054. ''' <summary>
  1055. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1056. ''' <para></para>
  1057. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1058. ''' <para></para>
  1059. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1060. ''' </summary>
  1061. ''' ----------------------------------------------------------------------------------------------------
  1062. ''' <example> This is a code example.
  1063. ''' <code>
  1064. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1065. ''' SendGMailText(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  1066. ''' </code>
  1067. ''' </example>
  1068. ''' ----------------------------------------------------------------------------------------------------
  1069. ''' <remarks>
  1070. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1071. ''' <para></para>
  1072. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1073. ''' </remarks>
  1074. ''' ----------------------------------------------------------------------------------------------------
  1075. ''' <param name="credential">
  1076. ''' The credential containing the username and password for the Gmail account.
  1077. ''' </param>
  1078. '''
  1079. ''' <param name="subject">
  1080. ''' The mail subject.
  1081. ''' </param>
  1082. '''
  1083. ''' <param name="body">
  1084. ''' The mail body.
  1085. ''' </param>
  1086. '''
  1087. ''' <param name="address">
  1088. ''' The target address that will receive our sent mail.
  1089. ''' </param>
  1090. '''
  1091. ''' <param name="attachments">
  1092. ''' The file(s) to attach in this e-mail.
  1093. ''' </param>
  1094. ''' ----------------------------------------------------------------------------------------------------
  1095. <DebuggerStepThrough>
  1096. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1097. ByVal subject As String,
  1098. ByVal body As String,
  1099. ByVal address As MailAddress,
  1100. ParamArray attachments As Attachment())
  1101.  
  1102. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  1103.  
  1104. End Sub
  1105.  
  1106. ''' ----------------------------------------------------------------------------------------------------
  1107. ''' <summary>
  1108. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1109. ''' <para></para>
  1110. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1111. ''' <para></para>
  1112. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1113. ''' </summary>
  1114. ''' ----------------------------------------------------------------------------------------------------
  1115. ''' <example> This is a code example.
  1116. ''' <code>
  1117. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1118. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  1119. ''' SendGMailText(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  1120. ''' </code>
  1121. ''' </example>
  1122. ''' ----------------------------------------------------------------------------------------------------
  1123. ''' <remarks>
  1124. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1125. ''' <para></para>
  1126. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1127. ''' </remarks>
  1128. ''' ----------------------------------------------------------------------------------------------------
  1129. ''' <param name="credential">
  1130. ''' The credential containing the username and password for the Gmail account.
  1131. ''' </param>
  1132. '''
  1133. ''' <param name="subject">
  1134. ''' The mail subject.
  1135. ''' </param>
  1136. '''
  1137. ''' <param name="body">
  1138. ''' The mail body.
  1139. ''' </param>
  1140. '''
  1141. ''' <param name="address">
  1142. ''' The target address that will receive our sent mail.
  1143. ''' </param>
  1144. '''
  1145. ''' <param name="attachments">
  1146. ''' The file(s) to attach in this e-mail.
  1147. ''' </param>
  1148. ''' ----------------------------------------------------------------------------------------------------
  1149. <DebuggerStepThrough>
  1150. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1151. ByVal subject As String,
  1152. ByVal body As String,
  1153. ByVal address As MailAddress,
  1154. ByVal attachments As Collection(Of Attachment))
  1155.  
  1156. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  1157.  
  1158. End Sub
  1159.  
  1160. ''' ----------------------------------------------------------------------------------------------------
  1161. ''' <summary>
  1162. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1163. ''' <para></para>
  1164. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1165. ''' <para></para>
  1166. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1167. ''' </summary>
  1168. ''' ----------------------------------------------------------------------------------------------------
  1169. ''' <example> This is a code example.
  1170. ''' <code>
  1171. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1172. ''' SendGMailText(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  1173. ''' </code>
  1174. ''' </example>
  1175. ''' ----------------------------------------------------------------------------------------------------
  1176. ''' <remarks>
  1177. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1178. ''' <para></para>
  1179. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1180. ''' </remarks>
  1181. ''' ----------------------------------------------------------------------------------------------------
  1182. ''' <param name="credential">
  1183. ''' The credential containing the username and password for the Gmail account.
  1184. ''' </param>
  1185. '''
  1186. ''' <param name="subject">
  1187. ''' The mail subject.
  1188. ''' </param>
  1189. '''
  1190. ''' <param name="body">
  1191. ''' The mail body.
  1192. ''' </param>
  1193. '''
  1194. ''' <param name="addresses">
  1195. ''' The target addresses that will receive our sent mail.
  1196. ''' </param>
  1197. ''' ----------------------------------------------------------------------------------------------------
  1198. <DebuggerStepThrough>
  1199. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1200. ByVal subject As String,
  1201. ByVal body As String,
  1202. ByVal addresses As String())
  1203.  
  1204. Dim addressCollection As New MailAddressCollection
  1205. For Each address As String In addresses
  1206. addressCollection.Add(New MailAddress(address))
  1207. Next address
  1208.  
  1209. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, addressCollection, attachments:=Nothing)
  1210.  
  1211. End Sub
  1212.  
  1213. ''' ----------------------------------------------------------------------------------------------------
  1214. ''' <summary>
  1215. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1216. ''' <para></para>
  1217. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1218. ''' <para></para>
  1219. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1220. ''' </summary>
  1221. ''' ----------------------------------------------------------------------------------------------------
  1222. ''' <example> This is a code example.
  1223. ''' <code>
  1224. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1225. ''' SendGMailText(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  1226. ''' </code>
  1227. ''' </example>
  1228. ''' ----------------------------------------------------------------------------------------------------
  1229. ''' <remarks>
  1230. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1231. ''' <para></para>
  1232. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1233. ''' </remarks>
  1234. ''' ----------------------------------------------------------------------------------------------------
  1235. ''' <param name="credential">
  1236. ''' The credential containing the username and password for the Gmail account.
  1237. ''' </param>
  1238. '''
  1239. ''' <param name="subject">
  1240. ''' The mail subject.
  1241. ''' </param>
  1242. '''
  1243. ''' <param name="body">
  1244. ''' The mail body.
  1245. ''' </param>
  1246. '''
  1247. ''' <param name="addresses">
  1248. ''' The target addresses that will receive our sent mail.
  1249. ''' </param>
  1250. '''
  1251. ''' <param name="attachments">
  1252. ''' The file(s) to attach in this e-mail.
  1253. ''' </param>
  1254. ''' ----------------------------------------------------------------------------------------------------
  1255. <DebuggerStepThrough>
  1256. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1257. ByVal subject As String,
  1258. ByVal body As String,
  1259. ByVal addresses As String(),
  1260. ParamArray attachments As Attachment())
  1261.  
  1262. Dim addressCollection As New MailAddressCollection
  1263. For Each address As String In addresses
  1264. addressCollection.Add(New MailAddress(address))
  1265. Next address
  1266.  
  1267. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  1268.  
  1269. End Sub
  1270.  
  1271. ''' ----------------------------------------------------------------------------------------------------
  1272. ''' <summary>
  1273. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1274. ''' <para></para>
  1275. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1276. ''' <para></para>
  1277. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1278. ''' </summary>
  1279. ''' ----------------------------------------------------------------------------------------------------
  1280. ''' <example> This is a code example.
  1281. ''' <code>
  1282. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1283. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  1284. ''' SendGMailText(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  1285. ''' </code>
  1286. ''' </example>
  1287. ''' ----------------------------------------------------------------------------------------------------
  1288. ''' <remarks>
  1289. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1290. ''' <para></para>
  1291. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1292. ''' </remarks>
  1293. ''' ----------------------------------------------------------------------------------------------------
  1294. ''' <param name="credential">
  1295. ''' The credential containing the username and password for the Gmail account.
  1296. ''' </param>
  1297. '''
  1298. ''' <param name="subject">
  1299. ''' The mail subject.
  1300. ''' </param>
  1301. '''
  1302. ''' <param name="body">
  1303. ''' The mail body.
  1304. ''' </param>
  1305. '''
  1306. ''' <param name="addresses">
  1307. ''' The target addresses that will receive our sent mail.
  1308. ''' </param>
  1309. '''
  1310. ''' <param name="attachments">
  1311. ''' The file(s) to attach in this e-mail.
  1312. ''' </param>
  1313. ''' ----------------------------------------------------------------------------------------------------
  1314. <DebuggerStepThrough>
  1315. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1316. ByVal subject As String,
  1317. ByVal body As String,
  1318. ByVal addresses As String(),
  1319. ByVal attachments As Collection(Of Attachment))
  1320.  
  1321. Dim addressCollection As New MailAddressCollection
  1322. For Each address As String In addresses
  1323. addressCollection.Add(New MailAddress(address))
  1324. Next address
  1325.  
  1326. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  1327.  
  1328. End Sub
  1329.  
  1330. ''' ----------------------------------------------------------------------------------------------------
  1331. ''' <summary>
  1332. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1333. ''' <para></para>
  1334. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1335. ''' <para></para>
  1336. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1337. ''' </summary>
  1338. ''' ----------------------------------------------------------------------------------------------------
  1339. ''' <example> This is a code example.
  1340. ''' <code>
  1341. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1342. ''' Dim addressCollection As New MailAddressCollection
  1343. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  1344. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  1345. ''' SendGMailText(credential, "Email Subject", "Message Body", addressCollection)
  1346. ''' </code>
  1347. ''' </example>
  1348. ''' ----------------------------------------------------------------------------------------------------
  1349. ''' <remarks>
  1350. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1351. ''' <para></para>
  1352. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1353. ''' </remarks>
  1354. ''' ----------------------------------------------------------------------------------------------------
  1355. ''' <param name="credential">
  1356. ''' The credential containing the username and password for the Gmail account.
  1357. ''' </param>
  1358. '''
  1359. ''' <param name="subject">
  1360. ''' The mail subject.
  1361. ''' </param>
  1362. '''
  1363. ''' <param name="body">
  1364. ''' The mail body.
  1365. ''' </param>
  1366. '''
  1367. ''' <param name="addresses">
  1368. ''' The target addresses that will receive our sent mail.
  1369. ''' </param>
  1370. ''' ----------------------------------------------------------------------------------------------------
  1371. <DebuggerStepThrough>
  1372. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1373. ByVal subject As String,
  1374. ByVal body As String,
  1375. ByVal addresses As MailAddressCollection)
  1376.  
  1377. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, addresses, attachments:=Nothing)
  1378.  
  1379. End Sub
  1380.  
  1381. ''' ----------------------------------------------------------------------------------------------------
  1382. ''' <summary>
  1383. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1384. ''' <para></para>
  1385. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1386. ''' <para></para>
  1387. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1388. ''' </summary>
  1389. ''' ----------------------------------------------------------------------------------------------------
  1390. ''' <example> This is a code example.
  1391. ''' <code>
  1392. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1393. ''' Dim addressCollection As New MailAddressCollection
  1394. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  1395. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  1396. ''' SendGMailText(credential, "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  1397. ''' </code>
  1398. ''' </example>
  1399. ''' ----------------------------------------------------------------------------------------------------
  1400. ''' <remarks>
  1401. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1402. ''' <para></para>
  1403. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1404. ''' </remarks>
  1405. ''' ----------------------------------------------------------------------------------------------------
  1406. ''' <param name="credential">
  1407. ''' The credential containing the username and password for the Gmail account.
  1408. ''' </param>
  1409. '''
  1410. ''' <param name="subject">
  1411. ''' The mail subject.
  1412. ''' </param>
  1413. '''
  1414. ''' <param name="body">
  1415. ''' The mail body.
  1416. ''' </param>
  1417. '''
  1418. ''' <param name="addresses">
  1419. ''' The target addresses that will receive our sent mail.
  1420. ''' </param>
  1421. '''
  1422. ''' <param name="attachments">
  1423. ''' The file(s) to attach in this e-mail.
  1424. ''' </param>
  1425. ''' ----------------------------------------------------------------------------------------------------
  1426. <DebuggerStepThrough>
  1427. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1428. ByVal subject As String,
  1429. ByVal body As String,
  1430. ByVal addresses As MailAddressCollection,
  1431. ParamArray attachments As Attachment())
  1432.  
  1433. Dim attachCol As New Collection(Of Attachment)
  1434. For Each attachment As Attachment In attachments
  1435. attachCol.Add(attachment)
  1436. Next attachment
  1437.  
  1438. MailUtil.SendGMailText(credential.UserName, credential.Password, subject, body, addresses, attachCol)
  1439.  
  1440. End Sub
  1441.  
  1442. ''' ----------------------------------------------------------------------------------------------------
  1443. ''' <summary>
  1444. ''' Sends a mail with a plain text body through Google GMail SMTP server.
  1445. ''' <para></para>
  1446. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1447. ''' <para></para>
  1448. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1449. ''' </summary>
  1450. ''' ----------------------------------------------------------------------------------------------------
  1451. ''' <example> This is a code example.
  1452. ''' <code>
  1453. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  1454. ''' Dim addressCollection As New MailAddressCollection
  1455. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  1456. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  1457. '''
  1458. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  1459. '''
  1460. ''' SendGMailText(credential, "Email Subject", "Message Body", addressCollection, attachments)
  1461. ''' </code>
  1462. ''' </example>
  1463. ''' ----------------------------------------------------------------------------------------------------
  1464. ''' <remarks>
  1465. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1466. ''' <para></para>
  1467. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1468. ''' </remarks>
  1469. ''' ----------------------------------------------------------------------------------------------------
  1470. ''' <param name="credential">
  1471. ''' The credential containing the username and password for the Gmail account.
  1472. ''' </param>
  1473. '''
  1474. ''' <param name="subject">
  1475. ''' The mail subject.
  1476. ''' </param>
  1477. '''
  1478. ''' <param name="body">
  1479. ''' The mail body.
  1480. ''' </param>
  1481. '''
  1482. ''' <param name="addresses">
  1483. ''' The target addresses that will receive our sent mail.
  1484. ''' </param>
  1485. '''
  1486. ''' <param name="attachments">
  1487. ''' The file(s) to attach in this e-mail.
  1488. ''' </param>
  1489. ''' ----------------------------------------------------------------------------------------------------
  1490. <DebuggerStepThrough>
  1491. Public Shared Sub SendGMailText(ByVal credential As NetworkCredential,
  1492. ByVal subject As String,
  1493. ByVal body As String,
  1494. ByVal addresses As MailAddressCollection,
  1495. ByVal attachments As Collection(Of Attachment))
  1496.  
  1497. MailUtil.SendGMail(credential.UserName, credential.Password, subject, body, addresses, attachments, isBodyHtml:=False)
  1498.  
  1499. End Sub
  1500.  
  1501. #End Region
  1502.  
  1503. #Region " HTML Body "
  1504.  
  1505. ''' ----------------------------------------------------------------------------------------------------
  1506. ''' <summary>
  1507. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1508. ''' <para></para>
  1509. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1510. ''' <para></para>
  1511. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1512. ''' </summary>
  1513. ''' ----------------------------------------------------------------------------------------------------
  1514. ''' <example> This is a code example.
  1515. ''' <code>
  1516. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Address@Server.com")
  1517. ''' </code>
  1518. ''' </example>
  1519. ''' ----------------------------------------------------------------------------------------------------
  1520. ''' <remarks>
  1521. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1522. ''' <para></para>
  1523. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1524. ''' </remarks>
  1525. ''' ----------------------------------------------------------------------------------------------------
  1526. ''' <param name="username">
  1527. ''' The username of the Gmail account.
  1528. ''' </param>
  1529. '''
  1530. ''' <param name="password">
  1531. ''' The password of the Gmail account.
  1532. ''' </param>
  1533. '''
  1534. ''' <param name="subject">
  1535. ''' The mail subject.
  1536. ''' </param>
  1537. '''
  1538. ''' <param name="body">
  1539. ''' The mail body.
  1540. ''' </param>
  1541. '''
  1542. ''' <param name="address">
  1543. ''' The target address that will receive our sent mail.
  1544. ''' </param>
  1545. ''' ----------------------------------------------------------------------------------------------------
  1546. <DebuggerStepThrough>
  1547. Public Shared Sub SendGMailHtml(ByVal username As String,
  1548. ByVal password As String,
  1549. ByVal subject As String,
  1550. ByVal body As String,
  1551. ByVal address As String)
  1552.  
  1553. MailUtil.SendGMailHtml(username, password, subject, body, {address})
  1554.  
  1555. End Sub
  1556.  
  1557. ''' ----------------------------------------------------------------------------------------------------
  1558. ''' <summary>
  1559. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1560. ''' <para></para>
  1561. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1562. ''' <para></para>
  1563. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1564. ''' </summary>
  1565. ''' ----------------------------------------------------------------------------------------------------
  1566. ''' <example> This is a code example.
  1567. ''' <code>
  1568. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  1569. ''' </code>
  1570. ''' </example>
  1571. ''' ----------------------------------------------------------------------------------------------------
  1572. ''' <remarks>
  1573. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1574. ''' <para></para>
  1575. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1576. ''' </remarks>
  1577. ''' ----------------------------------------------------------------------------------------------------
  1578. ''' <param name="username">
  1579. ''' The username of the Gmail account.
  1580. ''' </param>
  1581. '''
  1582. ''' <param name="password">
  1583. ''' The password of the Gmail account.
  1584. ''' </param>
  1585. '''
  1586. ''' <param name="subject">
  1587. ''' The mail subject.
  1588. ''' </param>
  1589. '''
  1590. ''' <param name="body">
  1591. ''' The mail body.
  1592. ''' </param>
  1593. '''
  1594. ''' <param name="address">
  1595. ''' The target address that will receive our sent mail.
  1596. ''' </param>
  1597. '''
  1598. ''' <param name="attachments">
  1599. ''' The file(s) to attach in this e-mail.
  1600. ''' </param>
  1601. ''' ----------------------------------------------------------------------------------------------------
  1602. <DebuggerStepThrough>
  1603. Public Shared Sub SendGMailHtml(ByVal username As String,
  1604. ByVal password As String,
  1605. ByVal subject As String,
  1606. ByVal body As String,
  1607. ByVal address As String,
  1608. ParamArray attachments As Attachment())
  1609.  
  1610. MailUtil.SendGMailHtml(username, password, subject, body, {address}, attachments)
  1611.  
  1612. End Sub
  1613.  
  1614. ''' ----------------------------------------------------------------------------------------------------
  1615. ''' <summary>
  1616. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1617. ''' <para></para>
  1618. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1619. ''' <para></para>
  1620. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1621. ''' </summary>
  1622. ''' ----------------------------------------------------------------------------------------------------
  1623. ''' <example> This is a code example.
  1624. ''' <code>
  1625. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  1626. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", attachments)
  1627. ''' </code>
  1628. ''' </example>
  1629. ''' ----------------------------------------------------------------------------------------------------
  1630. ''' <remarks>
  1631. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1632. ''' <para></para>
  1633. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1634. ''' </remarks>
  1635. ''' ----------------------------------------------------------------------------------------------------
  1636. ''' <param name="username">
  1637. ''' The username of the Gmail account.
  1638. ''' </param>
  1639. '''
  1640. ''' <param name="password">
  1641. ''' The password of the Gmail account.
  1642. ''' </param>
  1643. '''
  1644. ''' <param name="subject">
  1645. ''' The mail subject.
  1646. ''' </param>
  1647. '''
  1648. ''' <param name="body">
  1649. ''' The mail body.
  1650. ''' </param>
  1651. '''
  1652. ''' <param name="address">
  1653. ''' The target address that will receive our sent mail.
  1654. ''' </param>
  1655. '''
  1656. ''' <param name="attachments">
  1657. ''' The file(s) to attach in this e-mail.
  1658. ''' </param>
  1659. ''' ----------------------------------------------------------------------------------------------------
  1660. <DebuggerStepThrough>
  1661. Public Shared Sub SendGMailHtml(ByVal username As String,
  1662. ByVal password As String,
  1663. ByVal subject As String,
  1664. ByVal body As String,
  1665. ByVal address As String,
  1666. ByVal attachments As Collection(Of Attachment))
  1667.  
  1668. MailUtil.SendGMailHtml(username, password, subject, body, {address}, attachments)
  1669.  
  1670. End Sub
  1671.  
  1672. ''' ----------------------------------------------------------------------------------------------------
  1673. ''' <summary>
  1674. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1675. ''' <para></para>
  1676. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1677. ''' <para></para>
  1678. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1679. ''' </summary>
  1680. ''' ----------------------------------------------------------------------------------------------------
  1681. ''' <example> This is a code example.
  1682. ''' <code>
  1683. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  1684. ''' </code>
  1685. ''' </example>
  1686. ''' ----------------------------------------------------------------------------------------------------
  1687. ''' <remarks>
  1688. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1689. ''' <para></para>
  1690. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1691. ''' </remarks>
  1692. ''' ----------------------------------------------------------------------------------------------------
  1693. ''' <param name="username">
  1694. ''' The username of the Gmail account.
  1695. ''' </param>
  1696. '''
  1697. ''' <param name="password">
  1698. ''' The password of the Gmail account.
  1699. ''' </param>
  1700. '''
  1701. ''' <param name="subject">
  1702. ''' The mail subject.
  1703. ''' </param>
  1704. '''
  1705. ''' <param name="body">
  1706. ''' The mail body.
  1707. ''' </param>
  1708. '''
  1709. ''' <param name="address">
  1710. ''' The target address that will receive our sent mail.
  1711. ''' </param>
  1712. ''' ----------------------------------------------------------------------------------------------------
  1713. <DebuggerStepThrough>
  1714. Public Shared Sub SendGMailHtml(ByVal username As String,
  1715. ByVal password As String,
  1716. ByVal subject As String,
  1717. ByVal body As String,
  1718. ByVal address As MailAddress)
  1719.  
  1720. MailUtil.SendGMailHtml(username, password, subject, body, {address.Address})
  1721.  
  1722. End Sub
  1723.  
  1724. ''' ----------------------------------------------------------------------------------------------------
  1725. ''' <summary>
  1726. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1727. ''' <para></para>
  1728. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1729. ''' <para></para>
  1730. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1731. ''' </summary>
  1732. ''' ----------------------------------------------------------------------------------------------------
  1733. ''' <example> This is a code example.
  1734. ''' <code>
  1735. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  1736. ''' </code>
  1737. ''' </example>
  1738. ''' ----------------------------------------------------------------------------------------------------
  1739. ''' <remarks>
  1740. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1741. ''' <para></para>
  1742. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1743. ''' </remarks>
  1744. ''' ----------------------------------------------------------------------------------------------------
  1745. ''' <param name="username">
  1746. ''' The username of the Gmail account.
  1747. ''' </param>
  1748. '''
  1749. ''' <param name="password">
  1750. ''' The password of the Gmail account.
  1751. ''' </param>
  1752. '''
  1753. ''' <param name="subject">
  1754. ''' The mail subject.
  1755. ''' </param>
  1756. '''
  1757. ''' <param name="body">
  1758. ''' The mail body.
  1759. ''' </param>
  1760. '''
  1761. ''' <param name="address">
  1762. ''' The target address that will receive our sent mail.
  1763. ''' </param>
  1764. '''
  1765. ''' <param name="attachments">
  1766. ''' The file(s) to attach in this e-mail.
  1767. ''' </param>
  1768. ''' ----------------------------------------------------------------------------------------------------
  1769. <DebuggerStepThrough>
  1770. Public Shared Sub SendGMailHtml(ByVal username As String,
  1771. ByVal password As String,
  1772. ByVal subject As String,
  1773. ByVal body As String,
  1774. ByVal address As MailAddress,
  1775. ParamArray attachments As Attachment())
  1776.  
  1777. MailUtil.SendGMailHtml(username, password, subject, body, {address.Address}, attachments)
  1778.  
  1779. End Sub
  1780.  
  1781. ''' ----------------------------------------------------------------------------------------------------
  1782. ''' <summary>
  1783. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1784. ''' <para></para>
  1785. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1786. ''' <para></para>
  1787. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1788. ''' </summary>
  1789. ''' ----------------------------------------------------------------------------------------------------
  1790. ''' <example> This is a code example.
  1791. ''' <code>
  1792. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  1793. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  1794. ''' </code>
  1795. ''' </example>
  1796. ''' ----------------------------------------------------------------------------------------------------
  1797. ''' <remarks>
  1798. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1799. ''' <para></para>
  1800. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1801. ''' </remarks>
  1802. ''' ----------------------------------------------------------------------------------------------------
  1803. ''' <param name="username">
  1804. ''' The username of the Gmail account.
  1805. ''' </param>
  1806. '''
  1807. ''' <param name="password">
  1808. ''' The password of the Gmail account.
  1809. ''' </param>
  1810. '''
  1811. ''' <param name="subject">
  1812. ''' The mail subject.
  1813. ''' </param>
  1814. '''
  1815. ''' <param name="body">
  1816. ''' The mail body.
  1817. ''' </param>
  1818. '''
  1819. ''' <param name="address">
  1820. ''' The target address that will receive our sent mail.
  1821. ''' </param>
  1822. '''
  1823. ''' <param name="attachments">
  1824. ''' The file(s) to attach in this e-mail.
  1825. ''' </param>
  1826. ''' ----------------------------------------------------------------------------------------------------
  1827. <DebuggerStepThrough>
  1828. Public Shared Sub SendGMailHtml(ByVal username As String,
  1829. ByVal password As String,
  1830. ByVal subject As String,
  1831. ByVal body As String,
  1832. ByVal address As MailAddress,
  1833. ByVal attachments As Collection(Of Attachment))
  1834.  
  1835. MailUtil.SendGMailHtml(username, password, subject, body, {address.Address}, attachments)
  1836.  
  1837. End Sub
  1838.  
  1839. ''' ----------------------------------------------------------------------------------------------------
  1840. ''' <summary>
  1841. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1842. ''' <para></para>
  1843. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1844. ''' <para></para>
  1845. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1846. ''' </summary>
  1847. ''' ----------------------------------------------------------------------------------------------------
  1848. ''' <example> This is a code example.
  1849. ''' <code>
  1850. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  1851. ''' </code>
  1852. ''' </example>
  1853. ''' ----------------------------------------------------------------------------------------------------
  1854. ''' <remarks>
  1855. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1856. ''' <para></para>
  1857. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1858. ''' </remarks>
  1859. ''' ----------------------------------------------------------------------------------------------------
  1860. ''' <param name="username">
  1861. ''' The username of the Gmail account.
  1862. ''' </param>
  1863. '''
  1864. ''' <param name="password">
  1865. ''' The password of the Gmail account.
  1866. ''' </param>
  1867. '''
  1868. ''' <param name="subject">
  1869. ''' The mail subject.
  1870. ''' </param>
  1871. '''
  1872. ''' <param name="body">
  1873. ''' The mail body.
  1874. ''' </param>
  1875. '''
  1876. ''' <param name="addresses">
  1877. ''' The target addresses that will receive our sent mail.
  1878. ''' </param>
  1879. ''' ----------------------------------------------------------------------------------------------------
  1880. <DebuggerStepThrough>
  1881. Public Shared Sub SendGMailHtml(ByVal username As String,
  1882. ByVal password As String,
  1883. ByVal subject As String,
  1884. ByVal body As String,
  1885. ByVal addresses As String())
  1886.  
  1887. Dim addressCollection As New MailAddressCollection
  1888. For Each address As String In addresses
  1889. addressCollection.Add(New MailAddress(address))
  1890. Next address
  1891.  
  1892. MailUtil.SendGMailHtml(username, password, subject, body, addressCollection, attachments:=Nothing)
  1893.  
  1894. End Sub
  1895.  
  1896. ''' ----------------------------------------------------------------------------------------------------
  1897. ''' <summary>
  1898. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1899. ''' <para></para>
  1900. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1901. ''' <para></para>
  1902. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1903. ''' </summary>
  1904. ''' ----------------------------------------------------------------------------------------------------
  1905. ''' <example> This is a code example.
  1906. ''' <code>
  1907. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  1908. ''' </code>
  1909. ''' </example>
  1910. ''' ----------------------------------------------------------------------------------------------------
  1911. ''' <remarks>
  1912. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1913. ''' <para></para>
  1914. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1915. ''' </remarks>
  1916. ''' ----------------------------------------------------------------------------------------------------
  1917. ''' <param name="username">
  1918. ''' The username of the Gmail account.
  1919. ''' </param>
  1920. '''
  1921. ''' <param name="password">
  1922. ''' The password of the Gmail account.
  1923. ''' </param>
  1924. '''
  1925. ''' <param name="subject">
  1926. ''' The mail subject.
  1927. ''' </param>
  1928. '''
  1929. ''' <param name="body">
  1930. ''' The mail body.
  1931. ''' </param>
  1932. '''
  1933. ''' <param name="addresses">
  1934. ''' The target addresses that will receive our sent mail.
  1935. ''' </param>
  1936. '''
  1937. ''' <param name="attachments">
  1938. ''' The file(s) to attach in this e-mail.
  1939. ''' </param>
  1940. ''' ----------------------------------------------------------------------------------------------------
  1941. <DebuggerStepThrough>
  1942. Public Shared Sub SendGMailHtml(ByVal username As String,
  1943. ByVal password As String,
  1944. ByVal subject As String,
  1945. ByVal body As String,
  1946. ByVal addresses As String(),
  1947. ParamArray attachments As Attachment())
  1948.  
  1949. Dim addressCollection As New MailAddressCollection
  1950. For Each address As String In addresses
  1951. addressCollection.Add(New MailAddress(address))
  1952. Next address
  1953.  
  1954. MailUtil.SendGMailHtml(username, password, subject, body, addressCollection, attachments)
  1955.  
  1956. End Sub
  1957.  
  1958. ''' ----------------------------------------------------------------------------------------------------
  1959. ''' <summary>
  1960. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  1961. ''' <para></para>
  1962. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1963. ''' <para></para>
  1964. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1965. ''' </summary>
  1966. ''' ----------------------------------------------------------------------------------------------------
  1967. ''' <example> This is a code example.
  1968. ''' <code>
  1969. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  1970. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  1971. ''' </code>
  1972. ''' </example>
  1973. ''' ----------------------------------------------------------------------------------------------------
  1974. ''' <remarks>
  1975. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  1976. ''' <para></para>
  1977. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  1978. ''' </remarks>
  1979. ''' ----------------------------------------------------------------------------------------------------
  1980. ''' <param name="username">
  1981. ''' The username of the Gmail account.
  1982. ''' </param>
  1983. '''
  1984. ''' <param name="password">
  1985. ''' The password of the Gmail account.
  1986. ''' </param>
  1987. '''
  1988. ''' <param name="subject">
  1989. ''' The mail subject.
  1990. ''' </param>
  1991. '''
  1992. ''' <param name="body">
  1993. ''' The mail body.
  1994. ''' </param>
  1995. '''
  1996. ''' <param name="addresses">
  1997. ''' The target addresses that will receive our sent mail.
  1998. ''' </param>
  1999. '''
  2000. ''' <param name="attachments">
  2001. ''' The file(s) to attach in this e-mail.
  2002. ''' </param>
  2003. ''' ----------------------------------------------------------------------------------------------------
  2004. <DebuggerStepThrough>
  2005. Public Shared Sub SendGMailHtml(ByVal username As String,
  2006. ByVal password As String,
  2007. ByVal subject As String,
  2008. ByVal body As String,
  2009. ByVal addresses As String(),
  2010. ByVal attachments As Collection(Of Attachment))
  2011.  
  2012. Dim addressCollection As New MailAddressCollection
  2013. For Each address As String In addresses
  2014. addressCollection.Add(New MailAddress(address))
  2015. Next address
  2016.  
  2017. MailUtil.SendGMailHtml(username, password, subject, body, addressCollection, attachments)
  2018.  
  2019. End Sub
  2020.  
  2021. ''' ----------------------------------------------------------------------------------------------------
  2022. ''' <summary>
  2023. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2024. ''' <para></para>
  2025. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2026. ''' <para></para>
  2027. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2028. ''' </summary>
  2029. ''' ----------------------------------------------------------------------------------------------------
  2030. ''' <example> This is a code example.
  2031. ''' <code>
  2032. ''' Dim addressCollection As New MailAddressCollection
  2033. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  2034. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  2035. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection)
  2036. ''' </code>
  2037. ''' </example>
  2038. ''' ----------------------------------------------------------------------------------------------------
  2039. ''' <remarks>
  2040. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2041. ''' <para></para>
  2042. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2043. ''' </remarks>
  2044. ''' ----------------------------------------------------------------------------------------------------
  2045. ''' <param name="username">
  2046. ''' The username of the Gmail account.
  2047. ''' </param>
  2048. '''
  2049. ''' <param name="password">
  2050. ''' The password of the Gmail account.
  2051. ''' </param>
  2052. '''
  2053. ''' <param name="subject">
  2054. ''' The mail subject.
  2055. ''' </param>
  2056. '''
  2057. ''' <param name="body">
  2058. ''' The mail body.
  2059. ''' </param>
  2060. '''
  2061. ''' <param name="addresses">
  2062. ''' The target addresses that will receive our sent mail.
  2063. ''' </param>
  2064. ''' ----------------------------------------------------------------------------------------------------
  2065. <DebuggerStepThrough>
  2066. Public Shared Sub SendGMailHtml(ByVal username As String,
  2067. ByVal password As String,
  2068. ByVal subject As String,
  2069. ByVal body As String,
  2070. ByVal addresses As MailAddressCollection)
  2071.  
  2072. MailUtil.SendGMailHtml(username, password, subject, body, addresses, attachments:=Nothing)
  2073.  
  2074. End Sub
  2075.  
  2076. ''' ----------------------------------------------------------------------------------------------------
  2077. ''' <summary>
  2078. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2079. ''' <para></para>
  2080. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2081. ''' <para></para>
  2082. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2083. ''' </summary>
  2084. ''' ----------------------------------------------------------------------------------------------------
  2085. ''' <example> This is a code example.
  2086. ''' <code>
  2087. ''' Dim addressCollection As New MailAddressCollection
  2088. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  2089. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  2090. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  2091. ''' </code>
  2092. ''' </example>
  2093. ''' ----------------------------------------------------------------------------------------------------
  2094. ''' <remarks>
  2095. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2096. ''' <para></para>
  2097. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2098. ''' </remarks>
  2099. ''' ----------------------------------------------------------------------------------------------------
  2100. ''' <param name="username">
  2101. ''' The username of the Gmail account.
  2102. ''' </param>
  2103. '''
  2104. ''' <param name="password">
  2105. ''' The password of the Gmail account.
  2106. ''' </param>
  2107. '''
  2108. ''' <param name="subject">
  2109. ''' The mail subject.
  2110. ''' </param>
  2111. '''
  2112. ''' <param name="body">
  2113. ''' The mail body.
  2114. ''' </param>
  2115. '''
  2116. ''' <param name="addresses">
  2117. ''' The target addresses that will receive our sent mail.
  2118. ''' </param>
  2119. '''
  2120. ''' <param name="attachments">
  2121. ''' The file(s) to attach in this e-mail.
  2122. ''' </param>
  2123. ''' ----------------------------------------------------------------------------------------------------
  2124. <DebuggerStepThrough>
  2125. Public Shared Sub SendGMailHtml(ByVal username As String,
  2126. ByVal password As String,
  2127. ByVal subject As String,
  2128. ByVal body As String,
  2129. ByVal addresses As MailAddressCollection,
  2130. ParamArray attachments As Attachment())
  2131.  
  2132. Dim attachCol As New Collection(Of Attachment)
  2133. For Each attachment As Attachment In attachments
  2134. attachCol.Add(attachment)
  2135. Next attachment
  2136.  
  2137. MailUtil.SendGMailHtml(username, password, subject, body, addresses, attachCol)
  2138.  
  2139. End Sub
  2140.  
  2141. ''' ----------------------------------------------------------------------------------------------------
  2142. ''' <summary>
  2143. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2144. ''' <para></para>
  2145. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2146. ''' <para></para>
  2147. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2148. ''' </summary>
  2149. ''' ----------------------------------------------------------------------------------------------------
  2150. ''' <example> This is a code example.
  2151. ''' <code>
  2152. ''' Dim addressCollection As New MailAddressCollection
  2153. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  2154. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  2155. '''
  2156. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  2157. '''
  2158. ''' SendGMailHtml("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection, attachments)
  2159. ''' </code>
  2160. ''' </example>
  2161. ''' ----------------------------------------------------------------------------------------------------
  2162. ''' <remarks>
  2163. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2164. ''' <para></para>
  2165. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2166. ''' </remarks>
  2167. ''' ----------------------------------------------------------------------------------------------------
  2168. ''' <param name="username">
  2169. ''' The username of the Gmail account.
  2170. ''' </param>
  2171. '''
  2172. ''' <param name="password">
  2173. ''' The password of the Gmail account.
  2174. ''' </param>
  2175. '''
  2176. ''' <param name="subject">
  2177. ''' The mail subject.
  2178. ''' </param>
  2179. '''
  2180. ''' <param name="body">
  2181. ''' The mail body.
  2182. ''' </param>
  2183. '''
  2184. ''' <param name="addresses">
  2185. ''' The target addresses that will receive our sent mail.
  2186. ''' </param>
  2187. '''
  2188. ''' <param name="attachments">
  2189. ''' The file(s) to attach in this e-mail.
  2190. ''' </param>
  2191. ''' ----------------------------------------------------------------------------------------------------
  2192. <DebuggerStepThrough>
  2193. Public Shared Sub SendGMailHtml(ByVal username As String,
  2194. ByVal password As String,
  2195. ByVal subject As String,
  2196. ByVal body As String,
  2197. ByVal addresses As MailAddressCollection,
  2198. ByVal attachments As Collection(Of Attachment))
  2199.  
  2200. MailUtil.SendGMail(username, password, subject, body, addresses, attachments, isBodyHtml:=True)
  2201.  
  2202. End Sub
  2203.  
  2204. ''' ----------------------------------------------------------------------------------------------------
  2205. ''' <summary>
  2206. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2207. ''' <para></para>
  2208. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2209. ''' <para></para>
  2210. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2211. ''' </summary>
  2212. ''' ----------------------------------------------------------------------------------------------------
  2213. ''' <example> This is a code example.
  2214. ''' <code>
  2215. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2216. ''' SendGMailHtml(credential, "Email Subject", "Message Body", "Address@Server.com")
  2217. ''' </code>
  2218. ''' </example>
  2219. ''' ----------------------------------------------------------------------------------------------------
  2220. ''' <remarks>
  2221. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2222. ''' <para></para>
  2223. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2224. ''' </remarks>
  2225. ''' ----------------------------------------------------------------------------------------------------
  2226. ''' <param name="credential">
  2227. ''' The credential containing the username and password for the Gmail account.
  2228. ''' </param>
  2229. '''
  2230. ''' <param name="subject">
  2231. ''' The mail subject.
  2232. ''' </param>
  2233. '''
  2234. ''' <param name="body">
  2235. ''' The mail body.
  2236. ''' </param>
  2237. '''
  2238. ''' <param name="address">
  2239. ''' The target address that will receive our sent mail.
  2240. ''' </param>
  2241. ''' ----------------------------------------------------------------------------------------------------
  2242. <DebuggerStepThrough>
  2243. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2244. ByVal subject As String,
  2245. ByVal body As String,
  2246. ByVal address As String)
  2247.  
  2248. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, {address})
  2249.  
  2250. End Sub
  2251.  
  2252. ''' ----------------------------------------------------------------------------------------------------
  2253. ''' <summary>
  2254. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2255. ''' <para></para>
  2256. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2257. ''' <para></para>
  2258. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2259. ''' </summary>
  2260. ''' ----------------------------------------------------------------------------------------------------
  2261. ''' <example> This is a code example.
  2262. ''' <code>
  2263. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2264. ''' SendGMailHtml(credential, "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  2265. ''' </code>
  2266. ''' </example>
  2267. ''' ----------------------------------------------------------------------------------------------------
  2268. ''' <remarks>
  2269. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2270. ''' <para></para>
  2271. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2272. ''' </remarks>
  2273. ''' ----------------------------------------------------------------------------------------------------
  2274. ''' <param name="credential">
  2275. ''' The credential containing the username and password for the Gmail account.
  2276. ''' </param>
  2277. '''
  2278. ''' <param name="subject">
  2279. ''' The mail subject.
  2280. ''' </param>
  2281. '''
  2282. ''' <param name="body">
  2283. ''' The mail body.
  2284. ''' </param>
  2285. '''
  2286. ''' <param name="address">
  2287. ''' The target address that will receive our sent mail.
  2288. ''' </param>
  2289. '''
  2290. ''' <param name="attachments">
  2291. ''' The file(s) to attach in this e-mail.
  2292. ''' </param>
  2293. ''' ----------------------------------------------------------------------------------------------------
  2294. <DebuggerStepThrough>
  2295. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2296. ByVal subject As String,
  2297. ByVal body As String,
  2298. ByVal address As String,
  2299. ParamArray attachments As Attachment())
  2300.  
  2301. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, {address}, attachments)
  2302.  
  2303. End Sub
  2304.  
  2305. ''' ----------------------------------------------------------------------------------------------------
  2306. ''' <summary>
  2307. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2308. ''' <para></para>
  2309. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2310. ''' <para></para>
  2311. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2312. ''' </summary>
  2313. ''' ----------------------------------------------------------------------------------------------------
  2314. ''' <example> This is a code example.
  2315. ''' <code>
  2316. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2317. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  2318. ''' SendGMailHtml(credential, "Email Subject", "Message Body", "Address@Server.com", attachments)
  2319. ''' </code>
  2320. ''' </example>
  2321. ''' ----------------------------------------------------------------------------------------------------
  2322. ''' <remarks>
  2323. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2324. ''' <para></para>
  2325. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2326. ''' </remarks>
  2327. ''' ----------------------------------------------------------------------------------------------------
  2328. ''' <param name="credential">
  2329. ''' The credential containing the username and password for the Gmail account.
  2330. ''' </param>
  2331. '''
  2332. ''' <param name="subject">
  2333. ''' The mail subject.
  2334. ''' </param>
  2335. '''
  2336. ''' <param name="body">
  2337. ''' The mail body.
  2338. ''' </param>
  2339. '''
  2340. ''' <param name="address">
  2341. ''' The target address that will receive our sent mail.
  2342. ''' </param>
  2343. '''
  2344. ''' <param name="attachments">
  2345. ''' The file(s) to attach in this e-mail.
  2346. ''' </param>
  2347. ''' ----------------------------------------------------------------------------------------------------
  2348. <DebuggerStepThrough>
  2349. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2350. ByVal subject As String,
  2351. ByVal body As String,
  2352. ByVal address As String,
  2353. ByVal attachments As Collection(Of Attachment))
  2354.  
  2355. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, {address}, attachments)
  2356.  
  2357. End Sub
  2358.  
  2359. ''' ----------------------------------------------------------------------------------------------------
  2360. ''' <summary>
  2361. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2362. ''' <para></para>
  2363. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2364. ''' <para></para>
  2365. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2366. ''' </summary>
  2367. ''' ----------------------------------------------------------------------------------------------------
  2368. ''' <example> This is a code example.
  2369. ''' <code>
  2370. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2371. ''' SendGMailHtml(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  2372. ''' </code>
  2373. ''' </example>
  2374. ''' ----------------------------------------------------------------------------------------------------
  2375. ''' <remarks>
  2376. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2377. ''' <para></para>
  2378. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2379. ''' </remarks>
  2380. ''' ----------------------------------------------------------------------------------------------------
  2381. ''' <param name="credential">
  2382. ''' The credential containing the username and password for the Gmail account.
  2383. ''' </param>
  2384. '''
  2385. ''' <param name="subject">
  2386. ''' The mail subject.
  2387. ''' </param>
  2388. '''
  2389. ''' <param name="body">
  2390. ''' The mail body.
  2391. ''' </param>
  2392. '''
  2393. ''' <param name="address">
  2394. ''' The target address that will receive our sent mail.
  2395. ''' </param>
  2396. ''' ----------------------------------------------------------------------------------------------------
  2397. <DebuggerStepThrough>
  2398. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2399. ByVal subject As String,
  2400. ByVal body As String,
  2401. ByVal address As MailAddress)
  2402.  
  2403. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, {address.Address})
  2404.  
  2405. End Sub
  2406.  
  2407. ''' ----------------------------------------------------------------------------------------------------
  2408. ''' <summary>
  2409. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2410. ''' <para></para>
  2411. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2412. ''' <para></para>
  2413. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2414. ''' </summary>
  2415. ''' ----------------------------------------------------------------------------------------------------
  2416. ''' <example> This is a code example.
  2417. ''' <code>
  2418. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2419. ''' SendGMailHtml(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  2420. ''' </code>
  2421. ''' </example>
  2422. ''' ----------------------------------------------------------------------------------------------------
  2423. ''' <remarks>
  2424. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2425. ''' <para></para>
  2426. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2427. ''' </remarks>
  2428. ''' ----------------------------------------------------------------------------------------------------
  2429. ''' <param name="credential">
  2430. ''' The credential containing the username and password for the Gmail account.
  2431. ''' </param>
  2432. '''
  2433. ''' <param name="subject">
  2434. ''' The mail subject.
  2435. ''' </param>
  2436. '''
  2437. ''' <param name="body">
  2438. ''' The mail body.
  2439. ''' </param>
  2440. '''
  2441. ''' <param name="address">
  2442. ''' The target address that will receive our sent mail.
  2443. ''' </param>
  2444. '''
  2445. ''' <param name="attachments">
  2446. ''' The file(s) to attach in this e-mail.
  2447. ''' </param>
  2448. ''' ----------------------------------------------------------------------------------------------------
  2449. <DebuggerStepThrough>
  2450. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2451. ByVal subject As String,
  2452. ByVal body As String,
  2453. ByVal address As MailAddress,
  2454. ParamArray attachments As Attachment())
  2455.  
  2456. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  2457.  
  2458. End Sub
  2459.  
  2460. ''' ----------------------------------------------------------------------------------------------------
  2461. ''' <summary>
  2462. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2463. ''' <para></para>
  2464. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2465. ''' <para></para>
  2466. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2467. ''' </summary>
  2468. ''' ----------------------------------------------------------------------------------------------------
  2469. ''' <example> This is a code example.
  2470. ''' <code>
  2471. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2472. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  2473. ''' SendGMailHtml(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  2474. ''' </code>
  2475. ''' </example>
  2476. ''' ----------------------------------------------------------------------------------------------------
  2477. ''' <remarks>
  2478. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2479. ''' <para></para>
  2480. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2481. ''' </remarks>
  2482. ''' ----------------------------------------------------------------------------------------------------
  2483. ''' <param name="credential">
  2484. ''' The credential containing the username and password for the Gmail account.
  2485. ''' </param>
  2486. '''
  2487. ''' <param name="subject">
  2488. ''' The mail subject.
  2489. ''' </param>
  2490. '''
  2491. ''' <param name="body">
  2492. ''' The mail body.
  2493. ''' </param>
  2494. '''
  2495. ''' <param name="address">
  2496. ''' The target address that will receive our sent mail.
  2497. ''' </param>
  2498. '''
  2499. ''' <param name="attachments">
  2500. ''' The file(s) to attach in this e-mail.
  2501. ''' </param>
  2502. ''' ----------------------------------------------------------------------------------------------------
  2503. <DebuggerStepThrough>
  2504. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2505. ByVal subject As String,
  2506. ByVal body As String,
  2507. ByVal address As MailAddress,
  2508. ByVal attachments As Collection(Of Attachment))
  2509.  
  2510. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  2511.  
  2512. End Sub
  2513.  
  2514. ''' ----------------------------------------------------------------------------------------------------
  2515. ''' <summary>
  2516. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2517. ''' <para></para>
  2518. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2519. ''' <para></para>
  2520. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2521. ''' </summary>
  2522. ''' ----------------------------------------------------------------------------------------------------
  2523. ''' <example> This is a code example.
  2524. ''' <code>
  2525. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2526. ''' SendGMailHtml(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  2527. ''' </code>
  2528. ''' </example>
  2529. ''' ----------------------------------------------------------------------------------------------------
  2530. ''' <remarks>
  2531. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2532. ''' <para></para>
  2533. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2534. ''' </remarks>
  2535. ''' ----------------------------------------------------------------------------------------------------
  2536. ''' <param name="credential">
  2537. ''' The credential containing the username and password for the Gmail account.
  2538. ''' </param>
  2539. '''
  2540. ''' <param name="subject">
  2541. ''' The mail subject.
  2542. ''' </param>
  2543. '''
  2544. ''' <param name="body">
  2545. ''' The mail body.
  2546. ''' </param>
  2547. '''
  2548. ''' <param name="addresses">
  2549. ''' The target addresses that will receive our sent mail.
  2550. ''' </param>
  2551. ''' ----------------------------------------------------------------------------------------------------
  2552. <DebuggerStepThrough>
  2553. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2554. ByVal subject As String,
  2555. ByVal body As String,
  2556. ByVal addresses As String())
  2557.  
  2558. Dim addressCollection As New MailAddressCollection
  2559. For Each address As String In addresses
  2560. addressCollection.Add(New MailAddress(address))
  2561. Next address
  2562.  
  2563. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, addressCollection, attachments:=Nothing)
  2564.  
  2565. End Sub
  2566.  
  2567. ''' ----------------------------------------------------------------------------------------------------
  2568. ''' <summary>
  2569. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2570. ''' <para></para>
  2571. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2572. ''' <para></para>
  2573. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2574. ''' </summary>
  2575. ''' ----------------------------------------------------------------------------------------------------
  2576. ''' <example> This is a code example.
  2577. ''' <code>
  2578. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2579. ''' SendGMailHtml(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  2580. ''' </code>
  2581. ''' </example>
  2582. ''' ----------------------------------------------------------------------------------------------------
  2583. ''' <remarks>
  2584. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2585. ''' <para></para>
  2586. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2587. ''' </remarks>
  2588. ''' ----------------------------------------------------------------------------------------------------
  2589. ''' <param name="credential">
  2590. ''' The credential containing the username and password for the Gmail account.
  2591. ''' </param>
  2592. '''
  2593. ''' <param name="subject">
  2594. ''' The mail subject.
  2595. ''' </param>
  2596. '''
  2597. ''' <param name="body">
  2598. ''' The mail body.
  2599. ''' </param>
  2600. '''
  2601. ''' <param name="addresses">
  2602. ''' The target addresses that will receive our sent mail.
  2603. ''' </param>
  2604. '''
  2605. ''' <param name="attachments">
  2606. ''' The file(s) to attach in this e-mail.
  2607. ''' </param>
  2608. ''' ----------------------------------------------------------------------------------------------------
  2609. <DebuggerStepThrough>
  2610. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2611. ByVal subject As String,
  2612. ByVal body As String,
  2613. ByVal addresses As String(),
  2614. ParamArray attachments As Attachment())
  2615.  
  2616. Dim addressCollection As New MailAddressCollection
  2617. For Each address As String In addresses
  2618. addressCollection.Add(New MailAddress(address))
  2619. Next address
  2620.  
  2621. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  2622.  
  2623. End Sub
  2624.  
  2625. ''' ----------------------------------------------------------------------------------------------------
  2626. ''' <summary>
  2627. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2628. ''' <para></para>
  2629. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2630. ''' <para></para>
  2631. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2632. ''' </summary>
  2633. ''' ----------------------------------------------------------------------------------------------------
  2634. ''' <example> This is a code example.
  2635. ''' <code>
  2636. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2637. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  2638. ''' SendGMailHtml(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  2639. ''' </code>
  2640. ''' </example>
  2641. ''' ----------------------------------------------------------------------------------------------------
  2642. ''' <remarks>
  2643. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2644. ''' <para></para>
  2645. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2646. ''' </remarks>
  2647. ''' ----------------------------------------------------------------------------------------------------
  2648. ''' <param name="credential">
  2649. ''' The credential containing the username and password for the Gmail account.
  2650. ''' </param>
  2651. '''
  2652. ''' <param name="subject">
  2653. ''' The mail subject.
  2654. ''' </param>
  2655. '''
  2656. ''' <param name="body">
  2657. ''' The mail body.
  2658. ''' </param>
  2659. '''
  2660. ''' <param name="addresses">
  2661. ''' The target addresses that will receive our sent mail.
  2662. ''' </param>
  2663. '''
  2664. ''' <param name="attachments">
  2665. ''' The file(s) to attach in this e-mail.
  2666. ''' </param>
  2667. ''' ----------------------------------------------------------------------------------------------------
  2668. <DebuggerStepThrough>
  2669. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2670. ByVal subject As String,
  2671. ByVal body As String,
  2672. ByVal addresses As String(),
  2673. ByVal attachments As Collection(Of Attachment))
  2674.  
  2675. Dim addressCollection As New MailAddressCollection
  2676. For Each address As String In addresses
  2677. addressCollection.Add(New MailAddress(address))
  2678. Next address
  2679.  
  2680. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  2681.  
  2682. End Sub
  2683.  
  2684. ''' ----------------------------------------------------------------------------------------------------
  2685. ''' <summary>
  2686. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2687. ''' <para></para>
  2688. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2689. ''' <para></para>
  2690. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2691. ''' </summary>
  2692. ''' ----------------------------------------------------------------------------------------------------
  2693. ''' <example> This is a code example.
  2694. ''' <code>
  2695. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2696. ''' Dim addressCollection As New MailAddressCollection
  2697. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  2698. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  2699. ''' SendGMailHtml(credential, "Email Subject", "Message Body", addressCollection)
  2700. ''' </code>
  2701. ''' </example>
  2702. ''' ----------------------------------------------------------------------------------------------------
  2703. ''' <remarks>
  2704. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2705. ''' <para></para>
  2706. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2707. ''' </remarks>
  2708. ''' ----------------------------------------------------------------------------------------------------
  2709. ''' <param name="credential">
  2710. ''' The credential containing the username and password for the Gmail account.
  2711. ''' </param>
  2712. '''
  2713. ''' <param name="subject">
  2714. ''' The mail subject.
  2715. ''' </param>
  2716. '''
  2717. ''' <param name="body">
  2718. ''' The mail body.
  2719. ''' </param>
  2720. '''
  2721. ''' <param name="addresses">
  2722. ''' The target addresses that will receive our sent mail.
  2723. ''' </param>
  2724. ''' ----------------------------------------------------------------------------------------------------
  2725. <DebuggerStepThrough>
  2726. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2727. ByVal subject As String,
  2728. ByVal body As String,
  2729. ByVal addresses As MailAddressCollection)
  2730.  
  2731. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, addresses, attachments:=Nothing)
  2732.  
  2733. End Sub
  2734.  
  2735. ''' ----------------------------------------------------------------------------------------------------
  2736. ''' <summary>
  2737. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2738. ''' <para></para>
  2739. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2740. ''' <para></para>
  2741. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2742. ''' </summary>
  2743. ''' ----------------------------------------------------------------------------------------------------
  2744. ''' <example> This is a code example.
  2745. ''' <code>
  2746. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2747. ''' Dim addressCollection As New MailAddressCollection
  2748. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  2749. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  2750. ''' SendGMailHtml(credential, "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  2751. ''' </code>
  2752. ''' </example>
  2753. ''' ----------------------------------------------------------------------------------------------------
  2754. ''' <remarks>
  2755. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2756. ''' <para></para>
  2757. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2758. ''' </remarks>
  2759. ''' ----------------------------------------------------------------------------------------------------
  2760. ''' <param name="credential">
  2761. ''' The credential containing the username and password for the Gmail account.
  2762. ''' </param>
  2763. '''
  2764. ''' <param name="subject">
  2765. ''' The mail subject.
  2766. ''' </param>
  2767. '''
  2768. ''' <param name="body">
  2769. ''' The mail body.
  2770. ''' </param>
  2771. '''
  2772. ''' <param name="addresses">
  2773. ''' The target addresses that will receive our sent mail.
  2774. ''' </param>
  2775. '''
  2776. ''' <param name="attachments">
  2777. ''' The file(s) to attach in this e-mail.
  2778. ''' </param>
  2779. ''' ----------------------------------------------------------------------------------------------------
  2780. <DebuggerStepThrough>
  2781. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2782. ByVal subject As String,
  2783. ByVal body As String,
  2784. ByVal addresses As MailAddressCollection,
  2785. ParamArray attachments As Attachment())
  2786.  
  2787. Dim attachCol As New Collection(Of Attachment)
  2788. For Each attachment As Attachment In attachments
  2789. attachCol.Add(attachment)
  2790. Next attachment
  2791.  
  2792. MailUtil.SendGMailHtml(credential.UserName, credential.Password, subject, body, addresses, attachCol)
  2793.  
  2794. End Sub
  2795.  
  2796. ''' ----------------------------------------------------------------------------------------------------
  2797. ''' <summary>
  2798. ''' Sends a mail with a HTML body through Google GMail SMTP server.
  2799. ''' <para></para>
  2800. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2801. ''' <para></para>
  2802. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2803. ''' </summary>
  2804. ''' ----------------------------------------------------------------------------------------------------
  2805. ''' <example> This is a code example.
  2806. ''' <code>
  2807. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  2808. ''' Dim addressCollection As New MailAddressCollection
  2809. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  2810. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  2811. '''
  2812. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  2813. '''
  2814. ''' SendGMailHtml(credential, "Email Subject", "Message Body", addressCollection, attachments)
  2815. ''' </code>
  2816. ''' </example>
  2817. ''' ----------------------------------------------------------------------------------------------------
  2818. ''' <remarks>
  2819. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  2820. ''' <para></para>
  2821. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  2822. ''' </remarks>
  2823. ''' ----------------------------------------------------------------------------------------------------
  2824. ''' <param name="credential">
  2825. ''' The credential containing the username and password for the Gmail account.
  2826. ''' </param>
  2827. '''
  2828. ''' <param name="subject">
  2829. ''' The mail subject.
  2830. ''' </param>
  2831. '''
  2832. ''' <param name="body">
  2833. ''' The mail body.
  2834. ''' </param>
  2835. '''
  2836. ''' <param name="addresses">
  2837. ''' The target addresses that will receive our sent mail.
  2838. ''' </param>
  2839. '''
  2840. ''' <param name="attachments">
  2841. ''' The file(s) to attach in this e-mail.
  2842. ''' </param>
  2843. ''' ----------------------------------------------------------------------------------------------------
  2844. <DebuggerStepThrough>
  2845. Public Shared Sub SendGMailHtml(ByVal credential As NetworkCredential,
  2846. ByVal subject As String,
  2847. ByVal body As String,
  2848. ByVal addresses As MailAddressCollection,
  2849. ByVal attachments As Collection(Of Attachment))
  2850.  
  2851. MailUtil.SendGMail(credential.UserName, credential.Password, subject, body, addresses, attachments, isBodyHtml:=True)
  2852.  
  2853. End Sub
  2854.  
  2855. #End Region
  2856.  
  2857. #If NET45 OrElse NET46 Then
  2858.  
  2859. #Region " (ASYNC) Text Body "
  2860.  
  2861. ''' ----------------------------------------------------------------------------------------------------
  2862. ''' <summary>
  2863. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  2864. ''' </summary>
  2865. ''' ----------------------------------------------------------------------------------------------------
  2866. ''' <example> This is a code example.
  2867. ''' <code>
  2868. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", "Address@Server.com")
  2869. ''' </code>
  2870. ''' </example>
  2871. ''' ----------------------------------------------------------------------------------------------------
  2872. ''' <param name="username">
  2873. ''' The username of the Gmail account.
  2874. ''' </param>
  2875. '''
  2876. ''' <param name="password">
  2877. ''' The password of the Gmail account.
  2878. ''' </param>
  2879. '''
  2880. ''' <param name="subject">
  2881. ''' The mail subject.
  2882. ''' </param>
  2883. '''
  2884. ''' <param name="body">
  2885. ''' The mail body.
  2886. ''' </param>
  2887. '''
  2888. ''' <param name="address">
  2889. ''' The target address that will receive our sent mail.
  2890. ''' </param>
  2891. ''' ----------------------------------------------------------------------------------------------------
  2892. <DebuggerStepThrough>
  2893. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  2894. ByVal password As String,
  2895. ByVal subject As String,
  2896. ByVal body As String,
  2897. ByVal address As String) As Task
  2898.  
  2899. Await MailUtil.SendGMailAsyncText(username, password, subject, body, {address})
  2900.  
  2901. End Function
  2902.  
  2903. ''' ----------------------------------------------------------------------------------------------------
  2904. ''' <summary>
  2905. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  2906. ''' </summary>
  2907. ''' ----------------------------------------------------------------------------------------------------
  2908. ''' <example> This is a code example.
  2909. ''' <code>
  2910. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  2911. ''' </code>
  2912. ''' </example>
  2913. ''' ----------------------------------------------------------------------------------------------------
  2914. ''' <param name="username">
  2915. ''' The username of the Gmail account.
  2916. ''' </param>
  2917. '''
  2918. ''' <param name="password">
  2919. ''' The password of the Gmail account.
  2920. ''' </param>
  2921. '''
  2922. ''' <param name="subject">
  2923. ''' The mail subject.
  2924. ''' </param>
  2925. '''
  2926. ''' <param name="body">
  2927. ''' The mail body.
  2928. ''' </param>
  2929. '''
  2930. ''' <param name="address">
  2931. ''' The target address that will receive our sent mail.
  2932. ''' </param>
  2933. '''
  2934. ''' <param name="attachments">
  2935. ''' The file(s) to attach in this e-mail.
  2936. ''' </param>
  2937. ''' ----------------------------------------------------------------------------------------------------
  2938. <DebuggerStepThrough>
  2939. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  2940. ByVal password As String,
  2941. ByVal subject As String,
  2942. ByVal body As String,
  2943. ByVal address As String,
  2944. ParamArray attachments As Attachment()) As Task
  2945.  
  2946. Await MailUtil.SendGMailAsyncText(username, password, subject, body, {address}, attachments)
  2947.  
  2948. End Function
  2949.  
  2950. ''' ----------------------------------------------------------------------------------------------------
  2951. ''' <summary>
  2952. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  2953. ''' </summary>
  2954. ''' ----------------------------------------------------------------------------------------------------
  2955. ''' <example> This is a code example.
  2956. ''' <code>
  2957. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  2958. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", attachments)
  2959. ''' </code>
  2960. ''' </example>
  2961. ''' ----------------------------------------------------------------------------------------------------
  2962. ''' <param name="username">
  2963. ''' The username of the Gmail account.
  2964. ''' </param>
  2965. '''
  2966. ''' <param name="password">
  2967. ''' The password of the Gmail account.
  2968. ''' </param>
  2969. '''
  2970. ''' <param name="subject">
  2971. ''' The mail subject.
  2972. ''' </param>
  2973. '''
  2974. ''' <param name="body">
  2975. ''' The mail body.
  2976. ''' </param>
  2977. '''
  2978. ''' <param name="address">
  2979. ''' The target address that will receive our sent mail.
  2980. ''' </param>
  2981. '''
  2982. ''' <param name="attachments">
  2983. ''' The file(s) to attach in this e-mail.
  2984. ''' </param>
  2985. ''' ----------------------------------------------------------------------------------------------------
  2986. <DebuggerStepThrough>
  2987. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  2988. ByVal password As String,
  2989. ByVal subject As String,
  2990. ByVal body As String,
  2991. ByVal address As String,
  2992. ByVal attachments As Collection(Of Attachment)) As Task
  2993.  
  2994. Await MailUtil.SendGMailAsyncText(username, password, subject, body, {address}, attachments)
  2995.  
  2996. End Function
  2997.  
  2998. ''' ----------------------------------------------------------------------------------------------------
  2999. ''' <summary>
  3000. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3001. ''' </summary>
  3002. ''' ----------------------------------------------------------------------------------------------------
  3003. ''' <example> This is a code example.
  3004. ''' <code>
  3005. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  3006. ''' </code>
  3007. ''' </example>
  3008. ''' ----------------------------------------------------------------------------------------------------
  3009. ''' <param name="username">
  3010. ''' The username of the Gmail account.
  3011. ''' </param>
  3012. '''
  3013. ''' <param name="password">
  3014. ''' The password of the Gmail account.
  3015. ''' </param>
  3016. '''
  3017. ''' <param name="subject">
  3018. ''' The mail subject.
  3019. ''' </param>
  3020. '''
  3021. ''' <param name="body">
  3022. ''' The mail body.
  3023. ''' </param>
  3024. '''
  3025. ''' <param name="address">
  3026. ''' The target address that will receive our sent mail.
  3027. ''' </param>
  3028. ''' ----------------------------------------------------------------------------------------------------
  3029. <DebuggerStepThrough>
  3030. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3031. ByVal password As String,
  3032. ByVal subject As String,
  3033. ByVal body As String,
  3034. ByVal address As MailAddress) As Task
  3035.  
  3036. Await MailUtil.SendGMailAsyncText(username, password, subject, body, {address.Address})
  3037.  
  3038. End Function
  3039.  
  3040. ''' ----------------------------------------------------------------------------------------------------
  3041. ''' <summary>
  3042. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3043. ''' </summary>
  3044. ''' ----------------------------------------------------------------------------------------------------
  3045. ''' <example> This is a code example.
  3046. ''' <code>
  3047. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  3048. ''' </code>
  3049. ''' </example>
  3050. ''' ----------------------------------------------------------------------------------------------------
  3051. ''' <param name="username">
  3052. ''' The username of the Gmail account.
  3053. ''' </param>
  3054. '''
  3055. ''' <param name="password">
  3056. ''' The password of the Gmail account.
  3057. ''' </param>
  3058. '''
  3059. ''' <param name="subject">
  3060. ''' The mail subject.
  3061. ''' </param>
  3062. '''
  3063. ''' <param name="body">
  3064. ''' The mail body.
  3065. ''' </param>
  3066. '''
  3067. ''' <param name="address">
  3068. ''' The target address that will receive our sent mail.
  3069. ''' </param>
  3070. '''
  3071. ''' <param name="attachments">
  3072. ''' The file(s) to attach in this e-mail.
  3073. ''' </param>
  3074. ''' ----------------------------------------------------------------------------------------------------
  3075. <DebuggerStepThrough>
  3076. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3077. ByVal password As String,
  3078. ByVal subject As String,
  3079. ByVal body As String,
  3080. ByVal address As MailAddress,
  3081. ParamArray attachments As Attachment()) As Task
  3082.  
  3083. Await MailUtil.SendGMailAsyncText(username, password, subject, body, {address.Address}, attachments)
  3084.  
  3085. End Function
  3086.  
  3087. ''' ----------------------------------------------------------------------------------------------------
  3088. ''' <summary>
  3089. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3090. ''' </summary>
  3091. ''' ----------------------------------------------------------------------------------------------------
  3092. ''' <example> This is a code example.
  3093. ''' <code>
  3094. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3095. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  3096. ''' </code>
  3097. ''' </example>
  3098. ''' ----------------------------------------------------------------------------------------------------
  3099. ''' <param name="username">
  3100. ''' The username of the Gmail account.
  3101. ''' </param>
  3102. '''
  3103. ''' <param name="password">
  3104. ''' The password of the Gmail account.
  3105. ''' </param>
  3106. '''
  3107. ''' <param name="subject">
  3108. ''' The mail subject.
  3109. ''' </param>
  3110. '''
  3111. ''' <param name="body">
  3112. ''' The mail body.
  3113. ''' </param>
  3114. '''
  3115. ''' <param name="address">
  3116. ''' The target address that will receive our sent mail.
  3117. ''' </param>
  3118. '''
  3119. ''' <param name="attachments">
  3120. ''' The file(s) to attach in this e-mail.
  3121. ''' </param>
  3122. ''' ----------------------------------------------------------------------------------------------------
  3123. <DebuggerStepThrough>
  3124. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3125. ByVal password As String,
  3126. ByVal subject As String,
  3127. ByVal body As String,
  3128. ByVal address As MailAddress,
  3129. ByVal attachments As Collection(Of Attachment)) As Task
  3130.  
  3131. Await MailUtil.SendGMailAsyncText(username, password, subject, body, {address.Address}, attachments)
  3132.  
  3133. End Function
  3134.  
  3135. ''' ----------------------------------------------------------------------------------------------------
  3136. ''' <summary>
  3137. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3138. ''' </summary>
  3139. ''' ----------------------------------------------------------------------------------------------------
  3140. ''' <example> This is a code example.
  3141. ''' <code>
  3142. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  3143. ''' </code>
  3144. ''' </example>
  3145. ''' ----------------------------------------------------------------------------------------------------
  3146. ''' <param name="username">
  3147. ''' The username of the Gmail account.
  3148. ''' </param>
  3149. '''
  3150. ''' <param name="password">
  3151. ''' The password of the Gmail account.
  3152. ''' </param>
  3153. '''
  3154. ''' <param name="subject">
  3155. ''' The mail subject.
  3156. ''' </param>
  3157. '''
  3158. ''' <param name="body">
  3159. ''' The mail body.
  3160. ''' </param>
  3161. '''
  3162. ''' <param name="addresses">
  3163. ''' The target addresses that will receive our sent mail.
  3164. ''' </param>
  3165. ''' ----------------------------------------------------------------------------------------------------
  3166. <DebuggerStepThrough>
  3167. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3168. ByVal password As String,
  3169. ByVal subject As String,
  3170. ByVal body As String,
  3171. ByVal addresses As String()) As Task
  3172.  
  3173. Dim addressCollection As New MailAddressCollection
  3174. For Each address As String In addresses
  3175. addressCollection.Add(New MailAddress(address))
  3176. Next address
  3177.  
  3178. Await MailUtil.SendGMailAsyncText(username, password, subject, body, addressCollection)
  3179.  
  3180. End Function
  3181.  
  3182. ''' ----------------------------------------------------------------------------------------------------
  3183. ''' <summary>
  3184. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3185. ''' </summary>
  3186. ''' ----------------------------------------------------------------------------------------------------
  3187. ''' <example> This is a code example.
  3188. ''' <code>
  3189. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  3190. ''' </code>
  3191. ''' </example>
  3192. ''' ----------------------------------------------------------------------------------------------------
  3193. ''' <param name="username">
  3194. ''' The username of the Gmail account.
  3195. ''' </param>
  3196. '''
  3197. ''' <param name="password">
  3198. ''' The password of the Gmail account.
  3199. ''' </param>
  3200. '''
  3201. ''' <param name="subject">
  3202. ''' The mail subject.
  3203. ''' </param>
  3204. '''
  3205. ''' <param name="body">
  3206. ''' The mail body.
  3207. ''' </param>
  3208. '''
  3209. ''' <param name="addresses">
  3210. ''' The target addresses that will receive our sent mail.
  3211. ''' </param>
  3212. '''
  3213. ''' <param name="attachments">
  3214. ''' The file(s) to attach in this e-mail.
  3215. ''' </param>
  3216. ''' ----------------------------------------------------------------------------------------------------
  3217. <DebuggerStepThrough>
  3218. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3219. ByVal password As String,
  3220. ByVal subject As String,
  3221. ByVal body As String,
  3222. ByVal addresses As String(),
  3223. ParamArray attachments As Attachment()) As Task
  3224.  
  3225. Dim addressCollection As New MailAddressCollection
  3226. For Each address As String In addresses
  3227. addressCollection.Add(New MailAddress(address))
  3228. Next address
  3229.  
  3230. Await MailUtil.SendGMailAsyncText(username, password, subject, body, addressCollection, attachments)
  3231.  
  3232. End Function
  3233.  
  3234. ''' ----------------------------------------------------------------------------------------------------
  3235. ''' <summary>
  3236. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3237. ''' </summary>
  3238. ''' ----------------------------------------------------------------------------------------------------
  3239. ''' <example> This is a code example.
  3240. ''' <code>
  3241. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3242. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  3243. ''' </code>
  3244. ''' </example>
  3245. ''' ----------------------------------------------------------------------------------------------------
  3246. ''' <param name="username">
  3247. ''' The username of the Gmail account.
  3248. ''' </param>
  3249. '''
  3250. ''' <param name="password">
  3251. ''' The password of the Gmail account.
  3252. ''' </param>
  3253. '''
  3254. ''' <param name="subject">
  3255. ''' The mail subject.
  3256. ''' </param>
  3257. '''
  3258. ''' <param name="body">
  3259. ''' The mail body.
  3260. ''' </param>
  3261. '''
  3262. ''' <param name="addresses">
  3263. ''' The target addresses that will receive our sent mail.
  3264. ''' </param>
  3265. '''
  3266. ''' <param name="attachments">
  3267. ''' The file(s) to attach in this e-mail.
  3268. ''' </param>
  3269. ''' ----------------------------------------------------------------------------------------------------
  3270. <DebuggerStepThrough>
  3271. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3272. ByVal password As String,
  3273. ByVal subject As String,
  3274. ByVal body As String,
  3275. ByVal addresses As String(),
  3276. ByVal attachments As Collection(Of Attachment)) As Task
  3277.  
  3278. Dim addressCollection As New MailAddressCollection
  3279. For Each address As String In addresses
  3280. addressCollection.Add(New MailAddress(address))
  3281. Next address
  3282.  
  3283. Await MailUtil.SendGMailAsyncText(username, password, subject, body, addressCollection, attachments)
  3284.  
  3285. End Function
  3286.  
  3287. ''' ----------------------------------------------------------------------------------------------------
  3288. ''' <summary>
  3289. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3290. ''' </summary>
  3291. ''' ----------------------------------------------------------------------------------------------------
  3292. ''' <example> This is a code example.
  3293. ''' <code>
  3294. ''' Dim addressCollection As New MailAddressCollection
  3295. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  3296. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  3297. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection)
  3298. ''' </code>
  3299. ''' </example>
  3300. ''' ----------------------------------------------------------------------------------------------------
  3301. ''' <param name="username">
  3302. ''' The username of the Gmail account.
  3303. ''' </param>
  3304. '''
  3305. ''' <param name="password">
  3306. ''' The password of the Gmail account.
  3307. ''' </param>
  3308. '''
  3309. ''' <param name="subject">
  3310. ''' The mail subject.
  3311. ''' </param>
  3312. '''
  3313. ''' <param name="body">
  3314. ''' The mail body.
  3315. ''' </param>
  3316. '''
  3317. ''' <param name="addresses">
  3318. ''' The target addresses that will receive our sent mail.
  3319. ''' </param>
  3320. ''' ----------------------------------------------------------------------------------------------------
  3321. <DebuggerStepThrough>
  3322. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3323. ByVal password As String,
  3324. ByVal subject As String,
  3325. ByVal body As String,
  3326. ByVal addresses As MailAddressCollection) As Task
  3327.  
  3328. Await MailUtil.SendGMailAsyncText(username, password, subject, body, addresses, attachments:=Nothing)
  3329.  
  3330. End Function
  3331.  
  3332. ''' ----------------------------------------------------------------------------------------------------
  3333. ''' <summary>
  3334. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3335. ''' </summary>
  3336. ''' ----------------------------------------------------------------------------------------------------
  3337. ''' <example> This is a code example.
  3338. ''' <code>
  3339. ''' Dim addressCollection As New MailAddressCollection
  3340. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  3341. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  3342. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  3343. ''' </code>
  3344. ''' </example>
  3345. ''' ----------------------------------------------------------------------------------------------------
  3346. ''' <param name="username">
  3347. ''' The username of the Gmail account.
  3348. ''' </param>
  3349. '''
  3350. ''' <param name="password">
  3351. ''' The password of the Gmail account.
  3352. ''' </param>
  3353. '''
  3354. ''' <param name="subject">
  3355. ''' The mail subject.
  3356. ''' </param>
  3357. '''
  3358. ''' <param name="body">
  3359. ''' The mail body.
  3360. ''' </param>
  3361. '''
  3362. ''' <param name="addresses">
  3363. ''' The target addresses that will receive our sent mail.
  3364. ''' </param>
  3365. '''
  3366. ''' <param name="attachments">
  3367. ''' The file(s) to attach in this e-mail.
  3368. ''' </param>
  3369. ''' ----------------------------------------------------------------------------------------------------
  3370. <DebuggerStepThrough>
  3371. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3372. ByVal password As String,
  3373. ByVal subject As String,
  3374. ByVal body As String,
  3375. ByVal addresses As MailAddressCollection,
  3376. ParamArray attachments As Attachment()) As Task
  3377.  
  3378. Dim attachCol As New Collection(Of Attachment)
  3379. For Each attachment As Attachment In attachments
  3380. attachCol.Add(attachment)
  3381. Next attachment
  3382.  
  3383. Await MailUtil.SendGMailAsyncText(username, password, subject, body, addresses, attachCol)
  3384.  
  3385. End Function
  3386.  
  3387. ''' ----------------------------------------------------------------------------------------------------
  3388. ''' <summary>
  3389. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3390. ''' </summary>
  3391. ''' ----------------------------------------------------------------------------------------------------
  3392. ''' <example> This is a code example.
  3393. ''' <code>
  3394. ''' Dim addressCollection As New MailAddressCollection
  3395. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  3396. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  3397. '''
  3398. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3399. '''
  3400. ''' Await SendGMailAsyncText("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection, attachments)
  3401. ''' </code>
  3402. ''' </example>
  3403. ''' ----------------------------------------------------------------------------------------------------
  3404. ''' <param name="username">
  3405. ''' The username of the Gmail account.
  3406. ''' </param>
  3407. '''
  3408. ''' <param name="password">
  3409. ''' The password of the Gmail account.
  3410. ''' </param>
  3411. '''
  3412. ''' <param name="subject">
  3413. ''' The mail subject.
  3414. ''' </param>
  3415. '''
  3416. ''' <param name="body">
  3417. ''' The mail body.
  3418. ''' </param>
  3419. '''
  3420. ''' <param name="addresses">
  3421. ''' The target addresses that will receive our sent mail.
  3422. ''' </param>
  3423. '''
  3424. ''' <param name="attachments">
  3425. ''' The file(s) to attach in this e-mail.
  3426. ''' </param>
  3427. ''' ----------------------------------------------------------------------------------------------------
  3428. <DebuggerStepThrough>
  3429. Public Shared Async Function SendGMailAsyncText(ByVal username As String,
  3430. ByVal password As String,
  3431. ByVal subject As String,
  3432. ByVal body As String,
  3433. ByVal addresses As MailAddressCollection,
  3434. ByVal attachments As Collection(Of Attachment)) As Task
  3435.  
  3436. Await MailUtil.SendGMailAsync(username, password, subject, body, addresses, attachments, isBodyHtml:=False)
  3437.  
  3438. End Function
  3439.  
  3440. ''' ----------------------------------------------------------------------------------------------------
  3441. ''' <summary>
  3442. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3443. ''' </summary>
  3444. ''' ----------------------------------------------------------------------------------------------------
  3445. ''' <example> This is a code example.
  3446. ''' <code>
  3447. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3448. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", "Address@Server.com")
  3449. ''' </code>
  3450. ''' </example>
  3451. ''' ----------------------------------------------------------------------------------------------------
  3452. ''' <param name="credential">
  3453. ''' The credential containing the username and password for the Gmail account.
  3454. ''' </param>
  3455. '''
  3456. ''' <param name="subject">
  3457. ''' The mail subject.
  3458. ''' </param>
  3459. '''
  3460. ''' <param name="body">
  3461. ''' The mail body.
  3462. ''' </param>
  3463. '''
  3464. ''' <param name="address">
  3465. ''' The target address that will receive our sent mail.
  3466. ''' </param>
  3467. ''' ----------------------------------------------------------------------------------------------------
  3468. <DebuggerStepThrough>
  3469. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3470. ByVal subject As String,
  3471. ByVal body As String,
  3472. ByVal address As String) As Task
  3473.  
  3474. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, {address})
  3475.  
  3476. End Function
  3477.  
  3478. ''' ----------------------------------------------------------------------------------------------------
  3479. ''' <summary>
  3480. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3481. ''' </summary>
  3482. ''' ----------------------------------------------------------------------------------------------------
  3483. ''' <example> This is a code example.
  3484. ''' <code>
  3485. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3486. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  3487. ''' </code>
  3488. ''' </example>
  3489. ''' ----------------------------------------------------------------------------------------------------
  3490. ''' <param name="credential">
  3491. ''' The credential containing the username and password for the Gmail account.
  3492. ''' </param>
  3493. '''
  3494. ''' <param name="subject">
  3495. ''' The mail subject.
  3496. ''' </param>
  3497. '''
  3498. ''' <param name="body">
  3499. ''' The mail body.
  3500. ''' </param>
  3501. '''
  3502. ''' <param name="address">
  3503. ''' The target address that will receive our sent mail.
  3504. ''' </param>
  3505. '''
  3506. ''' <param name="attachments">
  3507. ''' The file(s) to attach in this e-mail.
  3508. ''' </param>
  3509. ''' ----------------------------------------------------------------------------------------------------
  3510. <DebuggerStepThrough>
  3511. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3512. ByVal subject As String,
  3513. ByVal body As String,
  3514. ByVal address As String,
  3515. ParamArray attachments As Attachment()) As Task
  3516.  
  3517. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, {address}, attachments)
  3518.  
  3519. End Function
  3520.  
  3521. ''' ----------------------------------------------------------------------------------------------------
  3522. ''' <summary>
  3523. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3524. ''' </summary>
  3525. ''' ----------------------------------------------------------------------------------------------------
  3526. ''' <example> This is a code example.
  3527. ''' <code>
  3528. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3529. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3530. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", "Address@Server.com", attachments)
  3531. ''' </code>
  3532. ''' </example>
  3533. ''' ----------------------------------------------------------------------------------------------------
  3534. ''' <param name="credential">
  3535. ''' The credential containing the username and password for the Gmail account.
  3536. ''' </param>
  3537. '''
  3538. ''' <param name="subject">
  3539. ''' The mail subject.
  3540. ''' </param>
  3541. '''
  3542. ''' <param name="body">
  3543. ''' The mail body.
  3544. ''' </param>
  3545. '''
  3546. ''' <param name="address">
  3547. ''' The target address that will receive our sent mail.
  3548. ''' </param>
  3549. '''
  3550. ''' <param name="attachments">
  3551. ''' The file(s) to attach in this e-mail.
  3552. ''' </param>
  3553. ''' ----------------------------------------------------------------------------------------------------
  3554. <DebuggerStepThrough>
  3555. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3556. ByVal subject As String,
  3557. ByVal body As String,
  3558. ByVal address As String,
  3559. ByVal attachments As Collection(Of Attachment)) As Task
  3560.  
  3561. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, {address}, attachments)
  3562.  
  3563. End Function
  3564.  
  3565. ''' ----------------------------------------------------------------------------------------------------
  3566. ''' <summary>
  3567. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3568. ''' </summary>
  3569. ''' ----------------------------------------------------------------------------------------------------
  3570. ''' <example> This is a code example.
  3571. ''' <code>
  3572. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3573. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  3574. ''' </code>
  3575. ''' </example>
  3576. ''' ----------------------------------------------------------------------------------------------------
  3577. ''' <param name="credential">
  3578. ''' The credential containing the username and password for the Gmail account.
  3579. ''' </param>
  3580. '''
  3581. ''' <param name="subject">
  3582. ''' The mail subject.
  3583. ''' </param>
  3584. '''
  3585. ''' <param name="body">
  3586. ''' The mail body.
  3587. ''' </param>
  3588. '''
  3589. ''' <param name="address">
  3590. ''' The target address that will receive our sent mail.
  3591. ''' </param>
  3592. ''' ----------------------------------------------------------------------------------------------------
  3593. <DebuggerStepThrough>
  3594. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3595. ByVal subject As String,
  3596. ByVal body As String,
  3597. ByVal address As MailAddress) As Task
  3598.  
  3599. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, {address.Address})
  3600.  
  3601. End Function
  3602.  
  3603. ''' ----------------------------------------------------------------------------------------------------
  3604. ''' <summary>
  3605. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3606. ''' </summary>
  3607. ''' ----------------------------------------------------------------------------------------------------
  3608. ''' <example> This is a code example.
  3609. ''' <code>
  3610. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3611. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  3612. ''' </code>
  3613. ''' </example>
  3614. ''' ----------------------------------------------------------------------------------------------------
  3615. ''' <param name="credential">
  3616. ''' The credential containing the username and password for the Gmail account.
  3617. ''' </param>
  3618. '''
  3619. ''' <param name="subject">
  3620. ''' The mail subject.
  3621. ''' </param>
  3622. '''
  3623. ''' <param name="body">
  3624. ''' The mail body.
  3625. ''' </param>
  3626. '''
  3627. ''' <param name="address">
  3628. ''' The target address that will receive our sent mail.
  3629. ''' </param>
  3630. '''
  3631. ''' <param name="attachments">
  3632. ''' The file(s) to attach in this e-mail.
  3633. ''' </param>
  3634. ''' ----------------------------------------------------------------------------------------------------
  3635. <DebuggerStepThrough>
  3636. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3637. ByVal subject As String,
  3638. ByVal body As String,
  3639. ByVal address As MailAddress,
  3640. ParamArray attachments As Attachment()) As Task
  3641.  
  3642. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  3643.  
  3644. End Function
  3645.  
  3646. ''' ----------------------------------------------------------------------------------------------------
  3647. ''' <summary>
  3648. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3649. ''' </summary>
  3650. ''' ----------------------------------------------------------------------------------------------------
  3651. ''' <example> This is a code example.
  3652. ''' <code>
  3653. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3654. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3655. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  3656. ''' </code>
  3657. ''' </example>
  3658. ''' ----------------------------------------------------------------------------------------------------
  3659. ''' <param name="credential">
  3660. ''' The credential containing the username and password for the Gmail account.
  3661. ''' </param>
  3662. '''
  3663. ''' <param name="subject">
  3664. ''' The mail subject.
  3665. ''' </param>
  3666. '''
  3667. ''' <param name="body">
  3668. ''' The mail body.
  3669. ''' </param>
  3670. '''
  3671. ''' <param name="address">
  3672. ''' The target address that will receive our sent mail.
  3673. ''' </param>
  3674. '''
  3675. ''' <param name="attachments">
  3676. ''' The file(s) to attach in this e-mail.
  3677. ''' </param>
  3678. ''' ----------------------------------------------------------------------------------------------------
  3679. <DebuggerStepThrough>
  3680. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3681. ByVal subject As String,
  3682. ByVal body As String,
  3683. ByVal address As MailAddress,
  3684. ByVal attachments As Collection(Of Attachment)) As Task
  3685.  
  3686. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  3687.  
  3688. End Function
  3689.  
  3690. ''' ----------------------------------------------------------------------------------------------------
  3691. ''' <summary>
  3692. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3693. ''' </summary>
  3694. ''' ----------------------------------------------------------------------------------------------------
  3695. ''' <example> This is a code example.
  3696. ''' <code>
  3697. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3698. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  3699. ''' </code>
  3700. ''' </example>
  3701. ''' ----------------------------------------------------------------------------------------------------
  3702. ''' <param name="credential">
  3703. ''' The credential containing the username and password for the Gmail account.
  3704. ''' </param>
  3705. '''
  3706. ''' <param name="subject">
  3707. ''' The mail subject.
  3708. ''' </param>
  3709. '''
  3710. ''' <param name="body">
  3711. ''' The mail body.
  3712. ''' </param>
  3713. '''
  3714. ''' <param name="addresses">
  3715. ''' The target addresses that will receive our sent mail.
  3716. ''' </param>
  3717. ''' ----------------------------------------------------------------------------------------------------
  3718. <DebuggerStepThrough>
  3719. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3720. ByVal subject As String,
  3721. ByVal body As String,
  3722. ByVal addresses As String()) As Task
  3723.  
  3724. Dim addressCollection As New MailAddressCollection
  3725. For Each address As String In addresses
  3726. addressCollection.Add(New MailAddress(address))
  3727. Next address
  3728.  
  3729. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, addressCollection)
  3730.  
  3731. End Function
  3732.  
  3733. ''' ----------------------------------------------------------------------------------------------------
  3734. ''' <summary>
  3735. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3736. ''' </summary>
  3737. ''' ----------------------------------------------------------------------------------------------------
  3738. ''' <example> This is a code example.
  3739. ''' <code>
  3740. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3741. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  3742. ''' </code>
  3743. ''' </example>
  3744. ''' ----------------------------------------------------------------------------------------------------
  3745. ''' <param name="credential">
  3746. ''' The credential containing the username and password for the Gmail account.
  3747. ''' </param>
  3748. '''
  3749. ''' <param name="subject">
  3750. ''' The mail subject.
  3751. ''' </param>
  3752. '''
  3753. ''' <param name="body">
  3754. ''' The mail body.
  3755. ''' </param>
  3756. '''
  3757. ''' <param name="addresses">
  3758. ''' The target addresses that will receive our sent mail.
  3759. ''' </param>
  3760. '''
  3761. ''' <param name="attachments">
  3762. ''' The file(s) to attach in this e-mail.
  3763. ''' </param>
  3764. ''' ----------------------------------------------------------------------------------------------------
  3765. <DebuggerStepThrough>
  3766. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3767. ByVal subject As String,
  3768. ByVal body As String,
  3769. ByVal addresses As String(),
  3770. ParamArray attachments As Attachment()) As Task
  3771.  
  3772. Dim addressCollection As New MailAddressCollection
  3773. For Each address As String In addresses
  3774. addressCollection.Add(New MailAddress(address))
  3775. Next address
  3776.  
  3777. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  3778.  
  3779. End Function
  3780.  
  3781. ''' ----------------------------------------------------------------------------------------------------
  3782. ''' <summary>
  3783. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3784. ''' </summary>
  3785. ''' ----------------------------------------------------------------------------------------------------
  3786. ''' <example> This is a code example.
  3787. ''' <code>
  3788. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3789. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3790. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  3791. ''' </code>
  3792. ''' </example>
  3793. ''' ----------------------------------------------------------------------------------------------------
  3794. ''' <param name="credential">
  3795. ''' The credential containing the username and password for the Gmail account.
  3796. ''' </param>
  3797. '''
  3798. ''' <param name="subject">
  3799. ''' The mail subject.
  3800. ''' </param>
  3801. '''
  3802. ''' <param name="body">
  3803. ''' The mail body.
  3804. ''' </param>
  3805. '''
  3806. ''' <param name="addresses">
  3807. ''' The target addresses that will receive our sent mail.
  3808. ''' </param>
  3809. '''
  3810. ''' <param name="attachments">
  3811. ''' The file(s) to attach in this e-mail.
  3812. ''' </param>
  3813. ''' ----------------------------------------------------------------------------------------------------
  3814. <DebuggerStepThrough>
  3815. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3816. ByVal subject As String,
  3817. ByVal body As String,
  3818. ByVal addresses As String(),
  3819. ByVal attachments As Collection(Of Attachment)) As Task
  3820.  
  3821. Dim addressCollection As New MailAddressCollection
  3822. For Each address As String In addresses
  3823. addressCollection.Add(New MailAddress(address))
  3824. Next address
  3825.  
  3826. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  3827.  
  3828. End Function
  3829.  
  3830. ''' ----------------------------------------------------------------------------------------------------
  3831. ''' <summary>
  3832. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3833. ''' </summary>
  3834. ''' ----------------------------------------------------------------------------------------------------
  3835. ''' <example> This is a code example.
  3836. ''' <code>
  3837. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3838. ''' Dim addressCollection As New MailAddressCollection
  3839. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  3840. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  3841. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", addressCollection)
  3842. ''' </code>
  3843. ''' </example>
  3844. ''' ----------------------------------------------------------------------------------------------------
  3845. ''' <param name="credential">
  3846. ''' The credential containing the username and password for the Gmail account.
  3847. ''' </param>
  3848. '''
  3849. ''' <param name="subject">
  3850. ''' The mail subject.
  3851. ''' </param>
  3852. '''
  3853. ''' <param name="body">
  3854. ''' The mail body.
  3855. ''' </param>
  3856. '''
  3857. ''' <param name="addresses">
  3858. ''' The target addresses that will receive our sent mail.
  3859. ''' </param>
  3860. ''' ----------------------------------------------------------------------------------------------------
  3861. <DebuggerStepThrough>
  3862. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3863. ByVal subject As String,
  3864. ByVal body As String,
  3865. ByVal addresses As MailAddressCollection) As Task
  3866.  
  3867. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, addresses, attachments:=Nothing)
  3868.  
  3869. End Function
  3870.  
  3871. ''' ----------------------------------------------------------------------------------------------------
  3872. ''' <summary>
  3873. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3874. ''' </summary>
  3875. ''' ----------------------------------------------------------------------------------------------------
  3876. ''' <example> This is a code example.
  3877. ''' <code>
  3878. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3879. ''' Dim addressCollection As New MailAddressCollection
  3880. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  3881. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  3882. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  3883. ''' </code>
  3884. ''' </example>
  3885. ''' ----------------------------------------------------------------------------------------------------
  3886. ''' <param name="credential">
  3887. ''' The credential containing the username and password for the Gmail account.
  3888. ''' </param>
  3889. '''
  3890. ''' <param name="subject">
  3891. ''' The mail subject.
  3892. ''' </param>
  3893. '''
  3894. ''' <param name="body">
  3895. ''' The mail body.
  3896. ''' </param>
  3897. '''
  3898. ''' <param name="addresses">
  3899. ''' The target addresses that will receive our sent mail.
  3900. ''' </param>
  3901. '''
  3902. ''' <param name="attachments">
  3903. ''' The file(s) to attach in this e-mail.
  3904. ''' </param>
  3905. ''' ----------------------------------------------------------------------------------------------------
  3906. <DebuggerStepThrough>
  3907. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3908. ByVal subject As String,
  3909. ByVal body As String,
  3910. ByVal addresses As MailAddressCollection,
  3911. ParamArray attachments As Attachment()) As Task
  3912.  
  3913. Dim attachCol As New Collection(Of Attachment)
  3914. For Each attachment As Attachment In attachments
  3915. attachCol.Add(attachment)
  3916. Next attachment
  3917.  
  3918. Await MailUtil.SendGMailAsyncText(credential.UserName, credential.Password, subject, body, addresses, attachCol)
  3919.  
  3920. End Function
  3921.  
  3922. ''' ----------------------------------------------------------------------------------------------------
  3923. ''' <summary>
  3924. ''' Asynchronously sends a mail with a plain text body through Google GMail SMTP server.
  3925. ''' </summary>
  3926. ''' ----------------------------------------------------------------------------------------------------
  3927. ''' <example> This is a code example.
  3928. ''' <code>
  3929. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  3930. ''' Dim addressCollection As New MailAddressCollection
  3931. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  3932. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  3933. '''
  3934. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  3935. '''
  3936. ''' Await SendGMailAsyncText(credential, "Email Subject", "Message Body", addressCollection, attachments)
  3937. ''' </code>
  3938. ''' </example>
  3939. ''' ----------------------------------------------------------------------------------------------------
  3940. ''' <param name="credential">
  3941. ''' The credential containing the username and password for the Gmail account.
  3942. ''' </param>
  3943. '''
  3944. ''' <param name="subject">
  3945. ''' The mail subject.
  3946. ''' </param>
  3947. '''
  3948. ''' <param name="body">
  3949. ''' The mail body.
  3950. ''' </param>
  3951. '''
  3952. ''' <param name="addresses">
  3953. ''' The target addresses that will receive our sent mail.
  3954. ''' </param>
  3955. '''
  3956. ''' <param name="attachments">
  3957. ''' The file(s) to attach in this e-mail.
  3958. ''' </param>
  3959. ''' ----------------------------------------------------------------------------------------------------
  3960. <DebuggerStepThrough>
  3961. Public Shared Async Function SendGMailAsyncText(ByVal credential As NetworkCredential,
  3962. ByVal subject As String,
  3963. ByVal body As String,
  3964. ByVal addresses As MailAddressCollection,
  3965. ByVal attachments As Collection(Of Attachment)) As Task
  3966.  
  3967. Await MailUtil.SendGMailAsync(credential.UserName, credential.Password, subject, body, addresses, attachments, isBodyHtml:=False)
  3968.  
  3969. End Function
  3970.  
  3971. #End Region
  3972.  
  3973. #Region " (ASYNC) HTML Body "
  3974.  
  3975. ''' ----------------------------------------------------------------------------------------------------
  3976. ''' <summary>
  3977. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  3978. ''' </summary>
  3979. ''' ----------------------------------------------------------------------------------------------------
  3980. ''' <example> This is a code example.
  3981. ''' <code>
  3982. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", "Address@Server.com")
  3983. ''' </code>
  3984. ''' </example>
  3985. ''' ----------------------------------------------------------------------------------------------------
  3986. ''' <param name="username">
  3987. ''' The username of the Gmail account.
  3988. ''' </param>
  3989. '''
  3990. ''' <param name="password">
  3991. ''' The password of the Gmail account.
  3992. ''' </param>
  3993. '''
  3994. ''' <param name="subject">
  3995. ''' The mail subject.
  3996. ''' </param>
  3997. '''
  3998. ''' <param name="body">
  3999. ''' The mail body.
  4000. ''' </param>
  4001. '''
  4002. ''' <param name="address">
  4003. ''' The target address that will receive our sent mail.
  4004. ''' </param>
  4005. ''' ----------------------------------------------------------------------------------------------------
  4006. <DebuggerStepThrough>
  4007. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4008. ByVal password As String,
  4009. ByVal subject As String,
  4010. ByVal body As String,
  4011. ByVal address As String) As Task
  4012.  
  4013. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, {address})
  4014.  
  4015. End Function
  4016.  
  4017. ''' ----------------------------------------------------------------------------------------------------
  4018. ''' <summary>
  4019. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4020. ''' </summary>
  4021. ''' ----------------------------------------------------------------------------------------------------
  4022. ''' <example> This is a code example.
  4023. ''' <code>
  4024. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  4025. ''' </code>
  4026. ''' </example>
  4027. ''' ----------------------------------------------------------------------------------------------------
  4028. ''' <param name="username">
  4029. ''' The username of the Gmail account.
  4030. ''' </param>
  4031. '''
  4032. ''' <param name="password">
  4033. ''' The password of the Gmail account.
  4034. ''' </param>
  4035. '''
  4036. ''' <param name="subject">
  4037. ''' The mail subject.
  4038. ''' </param>
  4039. '''
  4040. ''' <param name="body">
  4041. ''' The mail body.
  4042. ''' </param>
  4043. '''
  4044. ''' <param name="address">
  4045. ''' The target address that will receive our sent mail.
  4046. ''' </param>
  4047. '''
  4048. ''' <param name="attachments">
  4049. ''' The file(s) to attach in this e-mail.
  4050. ''' </param>
  4051. ''' ----------------------------------------------------------------------------------------------------
  4052. <DebuggerStepThrough>
  4053. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4054. ByVal password As String,
  4055. ByVal subject As String,
  4056. ByVal body As String,
  4057. ByVal address As String,
  4058. ParamArray attachments As Attachment()) As Task
  4059.  
  4060. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, {address}, attachments)
  4061.  
  4062. End Function
  4063.  
  4064. ''' ----------------------------------------------------------------------------------------------------
  4065. ''' <summary>
  4066. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4067. ''' </summary>
  4068. ''' ----------------------------------------------------------------------------------------------------
  4069. ''' <example> This is a code example.
  4070. ''' <code>
  4071. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4072. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", "Address@Server.com", attachments)
  4073. ''' </code>
  4074. ''' </example>
  4075. ''' ----------------------------------------------------------------------------------------------------
  4076. ''' <param name="username">
  4077. ''' The username of the Gmail account.
  4078. ''' </param>
  4079. '''
  4080. ''' <param name="password">
  4081. ''' The password of the Gmail account.
  4082. ''' </param>
  4083. '''
  4084. ''' <param name="subject">
  4085. ''' The mail subject.
  4086. ''' </param>
  4087. '''
  4088. ''' <param name="body">
  4089. ''' The mail body.
  4090. ''' </param>
  4091. '''
  4092. ''' <param name="address">
  4093. ''' The target address that will receive our sent mail.
  4094. ''' </param>
  4095. '''
  4096. ''' <param name="attachments">
  4097. ''' The file(s) to attach in this e-mail.
  4098. ''' </param>
  4099. ''' ----------------------------------------------------------------------------------------------------
  4100. <DebuggerStepThrough>
  4101. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4102. ByVal password As String,
  4103. ByVal subject As String,
  4104. ByVal body As String,
  4105. ByVal address As String,
  4106. ByVal attachments As Collection(Of Attachment)) As Task
  4107.  
  4108. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, {address}, attachments)
  4109.  
  4110. End Function
  4111.  
  4112. ''' ----------------------------------------------------------------------------------------------------
  4113. ''' <summary>
  4114. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4115. ''' </summary>
  4116. ''' ----------------------------------------------------------------------------------------------------
  4117. ''' <example> This is a code example.
  4118. ''' <code>
  4119. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  4120. ''' </code>
  4121. ''' </example>
  4122. ''' ----------------------------------------------------------------------------------------------------
  4123. ''' <param name="username">
  4124. ''' The username of the Gmail account.
  4125. ''' </param>
  4126. '''
  4127. ''' <param name="password">
  4128. ''' The password of the Gmail account.
  4129. ''' </param>
  4130. '''
  4131. ''' <param name="subject">
  4132. ''' The mail subject.
  4133. ''' </param>
  4134. '''
  4135. ''' <param name="body">
  4136. ''' The mail body.
  4137. ''' </param>
  4138. '''
  4139. ''' <param name="address">
  4140. ''' The target address that will receive our sent mail.
  4141. ''' </param>
  4142. ''' ----------------------------------------------------------------------------------------------------
  4143. <DebuggerStepThrough>
  4144. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4145. ByVal password As String,
  4146. ByVal subject As String,
  4147. ByVal body As String,
  4148. ByVal address As MailAddress) As Task
  4149.  
  4150. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, {address.Address})
  4151.  
  4152. End Function
  4153.  
  4154. ''' ----------------------------------------------------------------------------------------------------
  4155. ''' <summary>
  4156. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4157. ''' </summary>
  4158. ''' ----------------------------------------------------------------------------------------------------
  4159. ''' <example> This is a code example.
  4160. ''' <code>
  4161. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  4162. ''' </code>
  4163. ''' </example>
  4164. ''' ----------------------------------------------------------------------------------------------------
  4165. ''' <param name="username">
  4166. ''' The username of the Gmail account.
  4167. ''' </param>
  4168. '''
  4169. ''' <param name="password">
  4170. ''' The password of the Gmail account.
  4171. ''' </param>
  4172. '''
  4173. ''' <param name="subject">
  4174. ''' The mail subject.
  4175. ''' </param>
  4176. '''
  4177. ''' <param name="body">
  4178. ''' The mail body.
  4179. ''' </param>
  4180. '''
  4181. ''' <param name="address">
  4182. ''' The target address that will receive our sent mail.
  4183. ''' </param>
  4184. '''
  4185. ''' <param name="attachments">
  4186. ''' The file(s) to attach in this e-mail.
  4187. ''' </param>
  4188. ''' ----------------------------------------------------------------------------------------------------
  4189. <DebuggerStepThrough>
  4190. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4191. ByVal password As String,
  4192. ByVal subject As String,
  4193. ByVal body As String,
  4194. ByVal address As MailAddress,
  4195. ParamArray attachments As Attachment()) As Task
  4196.  
  4197. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, {address.Address}, attachments)
  4198.  
  4199. End Function
  4200.  
  4201. ''' ----------------------------------------------------------------------------------------------------
  4202. ''' <summary>
  4203. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4204. ''' </summary>
  4205. ''' ----------------------------------------------------------------------------------------------------
  4206. ''' <example> This is a code example.
  4207. ''' <code>
  4208. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4209. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  4210. ''' </code>
  4211. ''' </example>
  4212. ''' ----------------------------------------------------------------------------------------------------
  4213. ''' <param name="username">
  4214. ''' The username of the Gmail account.
  4215. ''' </param>
  4216. '''
  4217. ''' <param name="password">
  4218. ''' The password of the Gmail account.
  4219. ''' </param>
  4220. '''
  4221. ''' <param name="subject">
  4222. ''' The mail subject.
  4223. ''' </param>
  4224. '''
  4225. ''' <param name="body">
  4226. ''' The mail body.
  4227. ''' </param>
  4228. '''
  4229. ''' <param name="address">
  4230. ''' The target address that will receive our sent mail.
  4231. ''' </param>
  4232. '''
  4233. ''' <param name="attachments">
  4234. ''' The file(s) to attach in this e-mail.
  4235. ''' </param>
  4236. ''' ----------------------------------------------------------------------------------------------------
  4237. <DebuggerStepThrough>
  4238. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4239. ByVal password As String,
  4240. ByVal subject As String,
  4241. ByVal body As String,
  4242. ByVal address As MailAddress,
  4243. ByVal attachments As Collection(Of Attachment)) As Task
  4244.  
  4245. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, {address.Address}, attachments)
  4246.  
  4247. End Function
  4248.  
  4249. ''' ----------------------------------------------------------------------------------------------------
  4250. ''' <summary>
  4251. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4252. ''' </summary>
  4253. ''' ----------------------------------------------------------------------------------------------------
  4254. ''' <example> This is a code example.
  4255. ''' <code>
  4256. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  4257. ''' </code>
  4258. ''' </example>
  4259. ''' ----------------------------------------------------------------------------------------------------
  4260. ''' <param name="username">
  4261. ''' The username of the Gmail account.
  4262. ''' </param>
  4263. '''
  4264. ''' <param name="password">
  4265. ''' The password of the Gmail account.
  4266. ''' </param>
  4267. '''
  4268. ''' <param name="subject">
  4269. ''' The mail subject.
  4270. ''' </param>
  4271. '''
  4272. ''' <param name="body">
  4273. ''' The mail body.
  4274. ''' </param>
  4275. '''
  4276. ''' <param name="addresses">
  4277. ''' The target addresses that will receive our sent mail.
  4278. ''' </param>
  4279. ''' ----------------------------------------------------------------------------------------------------
  4280. <DebuggerStepThrough>
  4281. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4282. ByVal password As String,
  4283. ByVal subject As String,
  4284. ByVal body As String,
  4285. ByVal addresses As String()) As Task
  4286.  
  4287. Dim addressCollection As New MailAddressCollection
  4288. For Each address As String In addresses
  4289. addressCollection.Add(New MailAddress(address))
  4290. Next address
  4291.  
  4292. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, addressCollection)
  4293.  
  4294. End Function
  4295.  
  4296. ''' ----------------------------------------------------------------------------------------------------
  4297. ''' <summary>
  4298. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4299. ''' </summary>
  4300. ''' ----------------------------------------------------------------------------------------------------
  4301. ''' <example> This is a code example.
  4302. ''' <code>
  4303. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  4304. ''' </code>
  4305. ''' </example>
  4306. ''' ----------------------------------------------------------------------------------------------------
  4307. ''' <param name="username">
  4308. ''' The username of the Gmail account.
  4309. ''' </param>
  4310. '''
  4311. ''' <param name="password">
  4312. ''' The password of the Gmail account.
  4313. ''' </param>
  4314. '''
  4315. ''' <param name="subject">
  4316. ''' The mail subject.
  4317. ''' </param>
  4318. '''
  4319. ''' <param name="body">
  4320. ''' The mail body.
  4321. ''' </param>
  4322. '''
  4323. ''' <param name="addresses">
  4324. ''' The target addresses that will receive our sent mail.
  4325. ''' </param>
  4326. '''
  4327. ''' <param name="attachments">
  4328. ''' The file(s) to attach in this e-mail.
  4329. ''' </param>
  4330. ''' ----------------------------------------------------------------------------------------------------
  4331. <DebuggerStepThrough>
  4332. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4333. ByVal password As String,
  4334. ByVal subject As String,
  4335. ByVal body As String,
  4336. ByVal addresses As String(),
  4337. ParamArray attachments As Attachment()) As Task
  4338.  
  4339. Dim addressCollection As New MailAddressCollection
  4340. For Each address As String In addresses
  4341. addressCollection.Add(New MailAddress(address))
  4342. Next address
  4343.  
  4344. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, addressCollection, attachments)
  4345.  
  4346. End Function
  4347.  
  4348. ''' ----------------------------------------------------------------------------------------------------
  4349. ''' <summary>
  4350. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4351. ''' </summary>
  4352. ''' ----------------------------------------------------------------------------------------------------
  4353. ''' <example> This is a code example.
  4354. ''' <code>
  4355. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4356. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  4357. ''' </code>
  4358. ''' </example>
  4359. ''' ----------------------------------------------------------------------------------------------------
  4360. ''' <param name="username">
  4361. ''' The username of the Gmail account.
  4362. ''' </param>
  4363. '''
  4364. ''' <param name="password">
  4365. ''' The password of the Gmail account.
  4366. ''' </param>
  4367. '''
  4368. ''' <param name="subject">
  4369. ''' The mail subject.
  4370. ''' </param>
  4371. '''
  4372. ''' <param name="body">
  4373. ''' The mail body.
  4374. ''' </param>
  4375. '''
  4376. ''' <param name="addresses">
  4377. ''' The target addresses that will receive our sent mail.
  4378. ''' </param>
  4379. '''
  4380. ''' <param name="attachments">
  4381. ''' The file(s) to attach in this e-mail.
  4382. ''' </param>
  4383. ''' ----------------------------------------------------------------------------------------------------
  4384. <DebuggerStepThrough>
  4385. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4386. ByVal password As String,
  4387. ByVal subject As String,
  4388. ByVal body As String,
  4389. ByVal addresses As String(),
  4390. ByVal attachments As Collection(Of Attachment)) As Task
  4391.  
  4392. Dim addressCollection As New MailAddressCollection
  4393. For Each address As String In addresses
  4394. addressCollection.Add(New MailAddress(address))
  4395. Next address
  4396.  
  4397. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, addressCollection, attachments)
  4398.  
  4399. End Function
  4400.  
  4401. ''' ----------------------------------------------------------------------------------------------------
  4402. ''' <summary>
  4403. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4404. ''' </summary>
  4405. ''' ----------------------------------------------------------------------------------------------------
  4406. ''' <example> This is a code example.
  4407. ''' <code>
  4408. ''' Dim addressCollection As New MailAddressCollection
  4409. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  4410. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  4411. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection)
  4412. ''' </code>
  4413. ''' </example>
  4414. ''' ----------------------------------------------------------------------------------------------------
  4415. ''' <param name="username">
  4416. ''' The username of the Gmail account.
  4417. ''' </param>
  4418. '''
  4419. ''' <param name="password">
  4420. ''' The password of the Gmail account.
  4421. ''' </param>
  4422. '''
  4423. ''' <param name="subject">
  4424. ''' The mail subject.
  4425. ''' </param>
  4426. '''
  4427. ''' <param name="body">
  4428. ''' The mail body.
  4429. ''' </param>
  4430. '''
  4431. ''' <param name="addresses">
  4432. ''' The target addresses that will receive our sent mail.
  4433. ''' </param>
  4434. ''' ----------------------------------------------------------------------------------------------------
  4435. <DebuggerStepThrough>
  4436. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4437. ByVal password As String,
  4438. ByVal subject As String,
  4439. ByVal body As String,
  4440. ByVal addresses As MailAddressCollection) As Task
  4441.  
  4442. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, addresses, attachments:=Nothing)
  4443.  
  4444. End Function
  4445.  
  4446. ''' ----------------------------------------------------------------------------------------------------
  4447. ''' <summary>
  4448. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4449. ''' </summary>
  4450. ''' ----------------------------------------------------------------------------------------------------
  4451. ''' <example> This is a code example.
  4452. ''' <code>
  4453. ''' Dim addressCollection As New MailAddressCollection
  4454. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  4455. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  4456. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  4457. ''' </code>
  4458. ''' </example>
  4459. ''' ----------------------------------------------------------------------------------------------------
  4460. ''' <param name="username">
  4461. ''' The username of the Gmail account.
  4462. ''' </param>
  4463. '''
  4464. ''' <param name="password">
  4465. ''' The password of the Gmail account.
  4466. ''' </param>
  4467. '''
  4468. ''' <param name="subject">
  4469. ''' The mail subject.
  4470. ''' </param>
  4471. '''
  4472. ''' <param name="body">
  4473. ''' The mail body.
  4474. ''' </param>
  4475. '''
  4476. ''' <param name="addresses">
  4477. ''' The target addresses that will receive our sent mail.
  4478. ''' </param>
  4479. '''
  4480. ''' <param name="attachments">
  4481. ''' The file(s) to attach in this e-mail.
  4482. ''' </param>
  4483. ''' ----------------------------------------------------------------------------------------------------
  4484. <DebuggerStepThrough>
  4485. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4486. ByVal password As String,
  4487. ByVal subject As String,
  4488. ByVal body As String,
  4489. ByVal addresses As MailAddressCollection,
  4490. ParamArray attachments As Attachment()) As Task
  4491.  
  4492. Dim attachCol As New Collection(Of Attachment)
  4493. For Each attachment As Attachment In attachments
  4494. attachCol.Add(attachment)
  4495. Next attachment
  4496.  
  4497. Await MailUtil.SendGMailAsyncHtml(username, password, subject, body, addresses, attachCol)
  4498.  
  4499. End Function
  4500.  
  4501. ''' ----------------------------------------------------------------------------------------------------
  4502. ''' <summary>
  4503. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4504. ''' </summary>
  4505. ''' ----------------------------------------------------------------------------------------------------
  4506. ''' <example> This is a code example.
  4507. ''' <code>
  4508. ''' Dim addressCollection As New MailAddressCollection
  4509. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  4510. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  4511. '''
  4512. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4513. '''
  4514. ''' Await SendGMailAsyncHtml("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection, attachments)
  4515. ''' </code>
  4516. ''' </example>
  4517. ''' ----------------------------------------------------------------------------------------------------
  4518. ''' <param name="username">
  4519. ''' The username of the Gmail account.
  4520. ''' </param>
  4521. '''
  4522. ''' <param name="password">
  4523. ''' The password of the Gmail account.
  4524. ''' </param>
  4525. '''
  4526. ''' <param name="subject">
  4527. ''' The mail subject.
  4528. ''' </param>
  4529. '''
  4530. ''' <param name="body">
  4531. ''' The mail body.
  4532. ''' </param>
  4533. '''
  4534. ''' <param name="addresses">
  4535. ''' The target addresses that will receive our sent mail.
  4536. ''' </param>
  4537. '''
  4538. ''' <param name="attachments">
  4539. ''' The file(s) to attach in this e-mail.
  4540. ''' </param>
  4541. ''' ----------------------------------------------------------------------------------------------------
  4542. <DebuggerStepThrough>
  4543. Public Shared Async Function SendGMailAsyncHtml(ByVal username As String,
  4544. ByVal password As String,
  4545. ByVal subject As String,
  4546. ByVal body As String,
  4547. ByVal addresses As MailAddressCollection,
  4548. ByVal attachments As Collection(Of Attachment)) As Task
  4549.  
  4550. Await MailUtil.SendGMailAsync(username, password, subject, body, addresses, attachments, isBodyHtml:=False)
  4551.  
  4552. End Function
  4553.  
  4554. ''' ----------------------------------------------------------------------------------------------------
  4555. ''' <summary>
  4556. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4557. ''' </summary>
  4558. ''' ----------------------------------------------------------------------------------------------------
  4559. ''' <example> This is a code example.
  4560. ''' <code>
  4561. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4562. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", "Address@Server.com")
  4563. ''' </code>
  4564. ''' </example>
  4565. ''' ----------------------------------------------------------------------------------------------------
  4566. ''' <param name="credential">
  4567. ''' The credential containing the username and password for the Gmail account.
  4568. ''' </param>
  4569. '''
  4570. ''' <param name="subject">
  4571. ''' The mail subject.
  4572. ''' </param>
  4573. '''
  4574. ''' <param name="body">
  4575. ''' The mail body.
  4576. ''' </param>
  4577. '''
  4578. ''' <param name="address">
  4579. ''' The target address that will receive our sent mail.
  4580. ''' </param>
  4581. ''' ----------------------------------------------------------------------------------------------------
  4582. <DebuggerStepThrough>
  4583. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4584. ByVal subject As String,
  4585. ByVal body As String,
  4586. ByVal address As String) As Task
  4587.  
  4588. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, {address})
  4589.  
  4590. End Function
  4591.  
  4592. ''' ----------------------------------------------------------------------------------------------------
  4593. ''' <summary>
  4594. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4595. ''' </summary>
  4596. ''' ----------------------------------------------------------------------------------------------------
  4597. ''' <example> This is a code example.
  4598. ''' <code>
  4599. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4600. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", "Address@Server.com", New Attachment("C:\File.txt"))
  4601. ''' </code>
  4602. ''' </example>
  4603. ''' ----------------------------------------------------------------------------------------------------
  4604. ''' <param name="credential">
  4605. ''' The credential containing the username and password for the Gmail account.
  4606. ''' </param>
  4607. '''
  4608. ''' <param name="subject">
  4609. ''' The mail subject.
  4610. ''' </param>
  4611. '''
  4612. ''' <param name="body">
  4613. ''' The mail body.
  4614. ''' </param>
  4615. '''
  4616. ''' <param name="address">
  4617. ''' The target address that will receive our sent mail.
  4618. ''' </param>
  4619. '''
  4620. ''' <param name="attachments">
  4621. ''' The file(s) to attach in this e-mail.
  4622. ''' </param>
  4623. ''' ----------------------------------------------------------------------------------------------------
  4624. <DebuggerStepThrough>
  4625. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4626. ByVal subject As String,
  4627. ByVal body As String,
  4628. ByVal address As String,
  4629. ParamArray attachments As Attachment()) As Task
  4630.  
  4631. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, {address}, attachments)
  4632.  
  4633. End Function
  4634.  
  4635. ''' ----------------------------------------------------------------------------------------------------
  4636. ''' <summary>
  4637. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4638. ''' </summary>
  4639. ''' ----------------------------------------------------------------------------------------------------
  4640. ''' <example> This is a code example.
  4641. ''' <code>
  4642. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4643. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4644. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", "Address@Server.com", attachments)
  4645. ''' </code>
  4646. ''' </example>
  4647. ''' ----------------------------------------------------------------------------------------------------
  4648. ''' <param name="credential">
  4649. ''' The credential containing the username and password for the Gmail account.
  4650. ''' </param>
  4651. '''
  4652. ''' <param name="subject">
  4653. ''' The mail subject.
  4654. ''' </param>
  4655. '''
  4656. ''' <param name="body">
  4657. ''' The mail body.
  4658. ''' </param>
  4659. '''
  4660. ''' <param name="address">
  4661. ''' The target address that will receive our sent mail.
  4662. ''' </param>
  4663. '''
  4664. ''' <param name="attachments">
  4665. ''' The file(s) to attach in this e-mail.
  4666. ''' </param>
  4667. ''' ----------------------------------------------------------------------------------------------------
  4668. <DebuggerStepThrough>
  4669. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4670. ByVal subject As String,
  4671. ByVal body As String,
  4672. ByVal address As String,
  4673. ByVal attachments As Collection(Of Attachment)) As Task
  4674.  
  4675. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, {address}, attachments)
  4676.  
  4677. End Function
  4678.  
  4679. ''' ----------------------------------------------------------------------------------------------------
  4680. ''' <summary>
  4681. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4682. ''' </summary>
  4683. ''' ----------------------------------------------------------------------------------------------------
  4684. ''' <example> This is a code example.
  4685. ''' <code>
  4686. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4687. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"))
  4688. ''' </code>
  4689. ''' </example>
  4690. ''' ----------------------------------------------------------------------------------------------------
  4691. ''' <param name="credential">
  4692. ''' The credential containing the username and password for the Gmail account.
  4693. ''' </param>
  4694. '''
  4695. ''' <param name="subject">
  4696. ''' The mail subject.
  4697. ''' </param>
  4698. '''
  4699. ''' <param name="body">
  4700. ''' The mail body.
  4701. ''' </param>
  4702. '''
  4703. ''' <param name="address">
  4704. ''' The target address that will receive our sent mail.
  4705. ''' </param>
  4706. ''' ----------------------------------------------------------------------------------------------------
  4707. <DebuggerStepThrough>
  4708. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4709. ByVal subject As String,
  4710. ByVal body As String,
  4711. ByVal address As MailAddress) As Task
  4712.  
  4713. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, {address.Address})
  4714.  
  4715. End Function
  4716.  
  4717. ''' ----------------------------------------------------------------------------------------------------
  4718. ''' <summary>
  4719. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4720. ''' </summary>
  4721. ''' ----------------------------------------------------------------------------------------------------
  4722. ''' <example> This is a code example.
  4723. ''' <code>
  4724. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4725. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), New Attachment("C:\File.txt"))
  4726. ''' </code>
  4727. ''' </example>
  4728. ''' ----------------------------------------------------------------------------------------------------
  4729. ''' <param name="credential">
  4730. ''' The credential containing the username and password for the Gmail account.
  4731. ''' </param>
  4732. '''
  4733. ''' <param name="subject">
  4734. ''' The mail subject.
  4735. ''' </param>
  4736. '''
  4737. ''' <param name="body">
  4738. ''' The mail body.
  4739. ''' </param>
  4740. '''
  4741. ''' <param name="address">
  4742. ''' The target address that will receive our sent mail.
  4743. ''' </param>
  4744. '''
  4745. ''' <param name="attachments">
  4746. ''' The file(s) to attach in this e-mail.
  4747. ''' </param>
  4748. ''' ----------------------------------------------------------------------------------------------------
  4749. <DebuggerStepThrough>
  4750. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4751. ByVal subject As String,
  4752. ByVal body As String,
  4753. ByVal address As MailAddress,
  4754. ParamArray attachments As Attachment()) As Task
  4755.  
  4756. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  4757.  
  4758. End Function
  4759.  
  4760. ''' ----------------------------------------------------------------------------------------------------
  4761. ''' <summary>
  4762. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4763. ''' </summary>
  4764. ''' ----------------------------------------------------------------------------------------------------
  4765. ''' <example> This is a code example.
  4766. ''' <code>
  4767. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4768. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4769. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", New MailAddress("Address@Server.com"), attachments)
  4770. ''' </code>
  4771. ''' </example>
  4772. ''' ----------------------------------------------------------------------------------------------------
  4773. ''' <param name="credential">
  4774. ''' The credential containing the username and password for the Gmail account.
  4775. ''' </param>
  4776. '''
  4777. ''' <param name="subject">
  4778. ''' The mail subject.
  4779. ''' </param>
  4780. '''
  4781. ''' <param name="body">
  4782. ''' The mail body.
  4783. ''' </param>
  4784. '''
  4785. ''' <param name="address">
  4786. ''' The target address that will receive our sent mail.
  4787. ''' </param>
  4788. '''
  4789. ''' <param name="attachments">
  4790. ''' The file(s) to attach in this e-mail.
  4791. ''' </param>
  4792. ''' ----------------------------------------------------------------------------------------------------
  4793. <DebuggerStepThrough>
  4794. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4795. ByVal subject As String,
  4796. ByVal body As String,
  4797. ByVal address As MailAddress,
  4798. ByVal attachments As Collection(Of Attachment)) As Task
  4799.  
  4800. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, {address.Address}, attachments)
  4801.  
  4802. End Function
  4803.  
  4804. ''' ----------------------------------------------------------------------------------------------------
  4805. ''' <summary>
  4806. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4807. ''' </summary>
  4808. ''' ----------------------------------------------------------------------------------------------------
  4809. ''' <example> This is a code example.
  4810. ''' <code>
  4811. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4812. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"})
  4813. ''' </code>
  4814. ''' </example>
  4815. ''' ----------------------------------------------------------------------------------------------------
  4816. ''' <param name="credential">
  4817. ''' The credential containing the username and password for the Gmail account.
  4818. ''' </param>
  4819. '''
  4820. ''' <param name="subject">
  4821. ''' The mail subject.
  4822. ''' </param>
  4823. '''
  4824. ''' <param name="body">
  4825. ''' The mail body.
  4826. ''' </param>
  4827. '''
  4828. ''' <param name="addresses">
  4829. ''' The target addresses that will receive our sent mail.
  4830. ''' </param>
  4831. ''' ----------------------------------------------------------------------------------------------------
  4832. <DebuggerStepThrough>
  4833. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4834. ByVal subject As String,
  4835. ByVal body As String,
  4836. ByVal addresses As String()) As Task
  4837.  
  4838. Dim addressCollection As New MailAddressCollection
  4839. For Each address As String In addresses
  4840. addressCollection.Add(New MailAddress(address))
  4841. Next address
  4842.  
  4843. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, addressCollection)
  4844.  
  4845. End Function
  4846.  
  4847. ''' ----------------------------------------------------------------------------------------------------
  4848. ''' <summary>
  4849. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4850. ''' </summary>
  4851. ''' ----------------------------------------------------------------------------------------------------
  4852. ''' <example> This is a code example.
  4853. ''' <code>
  4854. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4855. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, New Attachment("C:\File.txt"))
  4856. ''' </code>
  4857. ''' </example>
  4858. ''' ----------------------------------------------------------------------------------------------------
  4859. ''' <param name="credential">
  4860. ''' The credential containing the username and password for the Gmail account.
  4861. ''' </param>
  4862. '''
  4863. ''' <param name="subject">
  4864. ''' The mail subject.
  4865. ''' </param>
  4866. '''
  4867. ''' <param name="body">
  4868. ''' The mail body.
  4869. ''' </param>
  4870. '''
  4871. ''' <param name="addresses">
  4872. ''' The target addresses that will receive our sent mail.
  4873. ''' </param>
  4874. '''
  4875. ''' <param name="attachments">
  4876. ''' The file(s) to attach in this e-mail.
  4877. ''' </param>
  4878. ''' ----------------------------------------------------------------------------------------------------
  4879. <DebuggerStepThrough>
  4880. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4881. ByVal subject As String,
  4882. ByVal body As String,
  4883. ByVal addresses As String(),
  4884. ParamArray attachments As Attachment()) As Task
  4885.  
  4886. Dim addressCollection As New MailAddressCollection
  4887. For Each address As String In addresses
  4888. addressCollection.Add(New MailAddress(address))
  4889. Next address
  4890.  
  4891. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  4892.  
  4893. End Function
  4894.  
  4895. ''' ----------------------------------------------------------------------------------------------------
  4896. ''' <summary>
  4897. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4898. ''' </summary>
  4899. ''' ----------------------------------------------------------------------------------------------------
  4900. ''' <example> This is a code example.
  4901. ''' <code>
  4902. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4903. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  4904. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", {"Address1@Server.com", "Address2@Server.com"}, attachments)
  4905. ''' </code>
  4906. ''' </example>
  4907. ''' ----------------------------------------------------------------------------------------------------
  4908. ''' <param name="credential">
  4909. ''' The credential containing the username and password for the Gmail account.
  4910. ''' </param>
  4911. '''
  4912. ''' <param name="subject">
  4913. ''' The mail subject.
  4914. ''' </param>
  4915. '''
  4916. ''' <param name="body">
  4917. ''' The mail body.
  4918. ''' </param>
  4919. '''
  4920. ''' <param name="addresses">
  4921. ''' The target addresses that will receive our sent mail.
  4922. ''' </param>
  4923. '''
  4924. ''' <param name="attachments">
  4925. ''' The file(s) to attach in this e-mail.
  4926. ''' </param>
  4927. ''' ----------------------------------------------------------------------------------------------------
  4928. <DebuggerStepThrough>
  4929. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4930. ByVal subject As String,
  4931. ByVal body As String,
  4932. ByVal addresses As String(),
  4933. ByVal attachments As Collection(Of Attachment)) As Task
  4934.  
  4935. Dim addressCollection As New MailAddressCollection
  4936. For Each address As String In addresses
  4937. addressCollection.Add(New MailAddress(address))
  4938. Next address
  4939.  
  4940. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, addressCollection, attachments)
  4941.  
  4942. End Function
  4943.  
  4944. ''' ----------------------------------------------------------------------------------------------------
  4945. ''' <summary>
  4946. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4947. ''' </summary>
  4948. ''' ----------------------------------------------------------------------------------------------------
  4949. ''' <example> This is a code example.
  4950. ''' <code>
  4951. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4952. ''' Dim addressCollection As New MailAddressCollection
  4953. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  4954. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  4955. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", addressCollection)
  4956. ''' </code>
  4957. ''' </example>
  4958. ''' ----------------------------------------------------------------------------------------------------
  4959. ''' <param name="credential">
  4960. ''' The credential containing the username and password for the Gmail account.
  4961. ''' </param>
  4962. '''
  4963. ''' <param name="subject">
  4964. ''' The mail subject.
  4965. ''' </param>
  4966. '''
  4967. ''' <param name="body">
  4968. ''' The mail body.
  4969. ''' </param>
  4970. '''
  4971. ''' <param name="addresses">
  4972. ''' The target addresses that will receive our sent mail.
  4973. ''' </param>
  4974. ''' ----------------------------------------------------------------------------------------------------
  4975. <DebuggerStepThrough>
  4976. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  4977. ByVal subject As String,
  4978. ByVal body As String,
  4979. ByVal addresses As MailAddressCollection) As Task
  4980.  
  4981. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, addresses, attachments:=Nothing)
  4982.  
  4983. End Function
  4984.  
  4985. ''' ----------------------------------------------------------------------------------------------------
  4986. ''' <summary>
  4987. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  4988. ''' </summary>
  4989. ''' ----------------------------------------------------------------------------------------------------
  4990. ''' <example> This is a code example.
  4991. ''' <code>
  4992. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  4993. ''' Dim addressCollection As New MailAddressCollection
  4994. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  4995. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  4996. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", addressCollection, New Attachment("C:\File.txt"))
  4997. ''' </code>
  4998. ''' </example>
  4999. ''' ----------------------------------------------------------------------------------------------------
  5000. ''' <param name="credential">
  5001. ''' The credential containing the username and password for the Gmail account.
  5002. ''' </param>
  5003. '''
  5004. ''' <param name="subject">
  5005. ''' The mail subject.
  5006. ''' </param>
  5007. '''
  5008. ''' <param name="body">
  5009. ''' The mail body.
  5010. ''' </param>
  5011. '''
  5012. ''' <param name="addresses">
  5013. ''' The target addresses that will receive our sent mail.
  5014. ''' </param>
  5015. '''
  5016. ''' <param name="attachments">
  5017. ''' The file(s) to attach in this e-mail.
  5018. ''' </param>
  5019. ''' ----------------------------------------------------------------------------------------------------
  5020. <DebuggerStepThrough>
  5021. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  5022. ByVal subject As String,
  5023. ByVal body As String,
  5024. ByVal addresses As MailAddressCollection,
  5025. ParamArray attachments As Attachment()) As Task
  5026.  
  5027. Dim attachCol As New Collection(Of Attachment)
  5028. For Each attachment As Attachment In attachments
  5029. attachCol.Add(attachment)
  5030. Next attachment
  5031.  
  5032. Await MailUtil.SendGMailAsyncHtml(credential.UserName, credential.Password, subject, body, addresses, attachCol)
  5033.  
  5034. End Function
  5035.  
  5036. ''' ----------------------------------------------------------------------------------------------------
  5037. ''' <summary>
  5038. ''' Asynchronously sends a mail with a HTML body through Google GMail SMTP server.
  5039. ''' </summary>
  5040. ''' ----------------------------------------------------------------------------------------------------
  5041. ''' <example> This is a code example.
  5042. ''' <code>
  5043. ''' Dim credential As New NetworkCredential("Username@Gmail.com", "Password")
  5044. ''' Dim addressCollection As New MailAddressCollection
  5045. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  5046. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  5047. '''
  5048. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  5049. '''
  5050. ''' Await SendGMailAsyncHtml(credential, "Email Subject", "Message Body", addressCollection, attachments)
  5051. ''' </code>
  5052. ''' </example>
  5053. ''' ----------------------------------------------------------------------------------------------------
  5054. ''' <param name="credential">
  5055. ''' The credential containing the username and password for the Gmail account.
  5056. ''' </param>
  5057. '''
  5058. ''' <param name="subject">
  5059. ''' The mail subject.
  5060. ''' </param>
  5061. '''
  5062. ''' <param name="body">
  5063. ''' The mail body.
  5064. ''' </param>
  5065. '''
  5066. ''' <param name="addresses">
  5067. ''' The target addresses that will receive our sent mail.
  5068. ''' </param>
  5069. '''
  5070. ''' <param name="attachments">
  5071. ''' The file(s) to attach in this e-mail.
  5072. ''' </param>
  5073. ''' ----------------------------------------------------------------------------------------------------
  5074. <DebuggerStepThrough>
  5075. Public Shared Async Function SendGMailAsyncHtml(ByVal credential As NetworkCredential,
  5076. ByVal subject As String,
  5077. ByVal body As String,
  5078. ByVal addresses As MailAddressCollection,
  5079. ByVal attachments As Collection(Of Attachment)) As Task
  5080.  
  5081. Await MailUtil.SendGMailAsync(credential.UserName, credential.Password, subject, body, addresses, attachments, isBodyHtml:=True)
  5082.  
  5083. End Function
  5084.  
  5085. #End Region
  5086.  
  5087. #End If
  5088.  
  5089. #End Region
  5090.  
  5091. #Region " Private Methods "
  5092.  
  5093. ''' ----------------------------------------------------------------------------------------------------
  5094. ''' <summary>
  5095. ''' Sends a mail through Google GMail SMTP server.
  5096. ''' <para></para>
  5097. ''' Note that in order to send SMTP messages, you must enable application access for your GMail account by following this url:
  5098. ''' <para></para>
  5099. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  5100. ''' </summary>
  5101. ''' ----------------------------------------------------------------------------------------------------
  5102. ''' <example> This is a code example.
  5103. ''' <code>
  5104. ''' Dim addressCollection As New MailAddressCollection
  5105. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  5106. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  5107. '''
  5108. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  5109. '''
  5110. ''' SendGMail("Username@Gmail.com", "Password", "Email Subject", "Message Body", addressCollection, attachments, isBodyHtml:=False)
  5111. ''' </code>
  5112. ''' </example>
  5113. ''' ----------------------------------------------------------------------------------------------------
  5114. ''' <remarks>
  5115. ''' In order to send SMTP messages, you must enable application access for your GMail account by following this url:
  5116. ''' <para></para>
  5117. ''' <see href="http://www.google.com/settings/security/lesssecureapps"/>
  5118. ''' </remarks>
  5119. ''' ----------------------------------------------------------------------------------------------------
  5120. ''' <param name="username">
  5121. ''' The username of the Gmail account.
  5122. ''' </param>
  5123. '''
  5124. ''' <param name="password">
  5125. ''' The password of the Gmail account.
  5126. ''' </param>
  5127. '''
  5128. ''' <param name="subject">
  5129. ''' The mail subject.
  5130. ''' </param>
  5131. '''
  5132. ''' <param name="body">
  5133. ''' The mail body.
  5134. ''' </param>
  5135. '''
  5136. ''' <param name="addresses">
  5137. ''' The target addresses that will receive our sent mail.
  5138. ''' </param>
  5139. '''
  5140. ''' <param name="attachments">
  5141. ''' The file(s) to attach in this e-mail.
  5142. ''' </param>
  5143. '''
  5144. ''' <param name="isBodyHtml">
  5145. ''' Indicates whether the mail body is html or plain text.
  5146. ''' </param>
  5147. ''' ----------------------------------------------------------------------------------------------------
  5148. <DebuggerStepThrough>
  5149. Private Shared Sub SendGMail(ByVal username As String,
  5150. ByVal password As String,
  5151. ByVal subject As String,
  5152. ByVal body As String,
  5153. ByVal addresses As MailAddressCollection,
  5154. ByVal attachments As Collection(Of Attachment),
  5155. ByVal isBodyHtml As Boolean)
  5156.  
  5157. Using msg As New MailMessage
  5158.  
  5159. For Each address As MailAddress In addresses
  5160. msg.To.Add(address)
  5161. Next address
  5162. msg.From = New MailAddress(username)
  5163. msg.Subject = subject
  5164. msg.IsBodyHtml = isBodyHtml
  5165. msg.Body = body
  5166. If (attachments IsNot Nothing) Then
  5167. For Each attachment As Attachment In attachments
  5168. msg.Attachments.Add(attachment)
  5169. Next attachment
  5170. End If
  5171.  
  5172. Using client As New SmtpClient()
  5173. With client
  5174. .Host = "smtp.gmail.com"
  5175. .Port = 587
  5176. .EnableSsl = True
  5177. .DeliveryMethod = SmtpDeliveryMethod.Network
  5178. .Timeout = CInt(TimeSpan.FromSeconds(60).TotalMilliseconds)
  5179. .Credentials = New NetworkCredential(username, password)
  5180. End With
  5181. client.Send(msg)
  5182. End Using
  5183.  
  5184. End Using
  5185.  
  5186. End Sub
  5187.  
  5188. #If NET45 OrElse NET46 Then
  5189.  
  5190. ''' ----------------------------------------------------------------------------------------------------
  5191. ''' <summary>
  5192. ''' Asynchronously sends a mail through Google GMail SMTP server.
  5193. ''' </summary>
  5194. ''' ----------------------------------------------------------------------------------------------------
  5195. ''' <example> This is a code example.
  5196. ''' <code>
  5197. ''' Dim addressCollection As New MailAddressCollection
  5198. ''' addressCollection.Add(New MailAddress("Address@Server.com"))
  5199. ''' addressCollection.Add(New MailAddress("Address2@Server.com"))
  5200. '''
  5201. ''' Dim attachments As New Collection(Of Attachment) From {New Attachment("C:\File1.txt"), New Attachment("C:\File2.txt")}
  5202. '''
  5203. ''' Await SendGMailAsync("Username@GMail.com", "Password", "Email Subject", "Message Body", addressCollection, attachments, isBodyHtml:=False)
  5204. ''' </code>
  5205. ''' </example>
  5206. ''' ----------------------------------------------------------------------------------------------------
  5207. ''' <param name="username">
  5208. ''' The username of the Gmail account.
  5209. ''' </param>
  5210. '''
  5211. ''' <param name="password">
  5212. ''' The password of the Gmail account.
  5213. ''' </param>
  5214. '''
  5215. ''' <param name="subject">
  5216. ''' The mail subject.
  5217. ''' </param>
  5218. '''
  5219. ''' <param name="body">
  5220. ''' The mail body.
  5221. ''' </param>
  5222. '''
  5223. ''' <param name="addresses">
  5224. ''' The target addresses that will receive our sent mail.
  5225. ''' </param>
  5226. '''
  5227. ''' <param name="attachments">
  5228. ''' The file(s) to attach in this e-mail.
  5229. ''' </param>
  5230. '''
  5231. ''' <param name="isBodyHtml">
  5232. ''' Indicates whether the mail body is html or plain text.
  5233. ''' </param>
  5234. ''' ----------------------------------------------------------------------------------------------------
  5235. <DebuggerStepThrough>
  5236. Public Shared Async Function SendGMailAsync(ByVal username As String,
  5237. ByVal password As String,
  5238. ByVal subject As String,
  5239. ByVal body As String,
  5240. ByVal addresses As MailAddressCollection,
  5241. ByVal attachments As Collection(Of Attachment),
  5242. ByVal isBodyHtml As Boolean) As Task
  5243.  
  5244. Using msg As New MailMessage
  5245.  
  5246. For Each address As MailAddress In addresses
  5247. msg.To.Add(address)
  5248. Next
  5249. msg.From = New MailAddress(username)
  5250. msg.Subject = subject
  5251. msg.IsBodyHtml = isBodyHtml
  5252. msg.Body = body
  5253. If (attachments IsNot Nothing) Then
  5254. For Each attachment As Attachment In attachments
  5255. msg.Attachments.Add(attachment)
  5256. Next attachment
  5257. End If
  5258.  
  5259. Using client As New SmtpClient()
  5260. With client
  5261. .Host = "smtp.gmail.com"
  5262. .Port = 587
  5263. .EnableSsl = True
  5264. .DeliveryMethod = SmtpDeliveryMethod.Network
  5265. .Timeout = CInt(TimeSpan.FromSeconds(60).TotalMilliseconds)
  5266. .Credentials = New NetworkCredential(username, password)
  5267. End With
  5268. Dim t As Task = client.SendMailAsync(msg)
  5269. Await t
  5270. End Using
  5271.  
  5272. End Using
  5273.  
  5274. End Function
  5275.  
  5276. #End If
  5277.  
  5278. #End Region
  5279.  
  5280. End Class
  5281.  
  5282. End Namespace
  5283.  
  5284. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement