ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¨S¦³©w¸q³o­Ósub©Îfunction

[µo°Ý] ¨S¦³©w¸q³o­Ósub©Îfunction

¦U¦ì¤j¤j¦n¡G

³Ìªñ¦b³]©wExcelªí®æ¥ÎVBA Email¥X¥h¡A
¥H¤Uµ{¦¡½X­ì¥»³]©w¦n¤F¡A¤@¤Á¥¿±`¥i¥Î¡C
¦]¬°±N¤£¬ÛÃöªº¨ä¥L¼Ò²Õ§R°£«á¡A³o­Ó¼Ò²Õ°õ¦æ®É«o¥X²{¡u¨S¦³©w¸q³o­Ósub©Îfunction¡v¡A
µM«á¿ù»~°T®§°±¦bSub CDO_TEST_OK()
¦ÓRangetoHTML¥X²{¤Ï¥Õ¡A
µ{¦¡½X¦p¤U¡A½Ð¦U¦ì¤j¤jÀ°À°¦£¡AÁÂÁÂ~~
  1. Sub CDO_TEST_OK()


  2. Dim objCDO As Object
  3. Dim strCfg As String
  4. Set objCDO = CreateObject("CDO.Message")
  5. strCfg = "http://schemas.microsoft.com/cdo/configuration/"

  6. With objCDO

  7. '.Sender = ""   '

  8. .From = "[email protected]"  '±H¥óªÌ
  9. .To = "[email protected]"   '±Hµ¹½Ö

  10. '.Fields("urn:schemas:mailheader:X-Priority") = 1 ' Priority = PriorityUrgent °ªÀu¥ý¶¶§Ç
  11. '.Fields("urn:schemas:mailheader:return-receipt-to") = "" ' ­n¨DŪ¨ú¦^±ø
  12. ' .Fields("urn:schemas:httpmail:importance") = 2 ' Importance = High
  13. ' .Fields("urn:schemas:httpmail:priority") = 1 ' Priority = PriorityUrgent

  14. .Fields.Update ' §ó·sÄæ¦ì
  15. .Subject = "Salary " & Range("A8") & "-" & Range("C8") '¥D¦®


  16. '.TextBody = "ORZ" ' Text ¤å¦r®æ¦¡«H¥ó¤º®e
  17. ' ©Î HTML ºô­¶®æ¦¡«H¥ó¤º®e
  18. .HTMLBody = "<HTML>" & _
  19. "<BODY>" & _
  20. "<table border=""1"" width=""100%"">" & _
  21. "<tr><td>I</td><td>am</td><td>Hammer</td><td>!</td></tr>" & _
  22. "<tr><td>Who</td><td>r</td><td>u</td><td>?</td></tr>" & _
  23. "</table>" & _
  24. "</BODY>" & _
  25. "</HTML>"
  26. .HTMLBody = RangetoHTML(Range("A1:J31")) '¶l¥ó¤º¤å(¬°EXCELªºªí®æ½d³ò)½Ð¨Ì»Ý¨D­×§ï

  27. '.AddAttachment "C:\AttFile.zip" ' ªþ¥[ÀÉ®×
  28. '.CC = "°Æ¥»@yahoo.com.tw" ' °Æ¥»
  29. '.BCC = "±K¥ó°Æ¥»@hotmail.com.tw" ' ±K¥ó°Æ¥»
  30. .Configuration(strCfg & "sendusing") = 2 ' Sendusing = SendUsingPort

  31. .Configuration(strCfg & "smtpserver") = "xxxs.com.tw" ' SMTP Server

  32. '.Configuration(strCfg & "smtpserver") = "msa.hinet.net" ' SMTP Server


  33. ' .Configuration(strCfg & "smtpserverport") = 25 ' SMTP Server Port ( ¹w³]§Y¬° 25 )
  34. ' SMTP Server ¦p»Ýµn¿ý , «h»Ý³]©w UserName / Password
  35. ' .Configuration(strCfg & "sendusername") = "UserName" ' Send User Name
  36. ' .Configuration(strCfg & "sendpassword") = "Password" ' Send Password
  37. .Configuration.Fields.Update ' §ó·s (Äæ¦ì) ²ÕºA
  38. ' .DSNOptions = 4 ' ¦^¶Ç«H¥ó¶Ç°eª¬ºA
  39. ' cdoDSNDefault = 0 , DSN commands are issued.
  40. ' cdoDSNDelay = 8 , Return a DSN if delivery is delayed.
  41. ' cdoDSNFailure = 2 , Return a DSN if delivery fails.
  42. ' cdoDSNNever = 1 , No DSNs are issued.
  43. ' cdoDSNSuccess = 4 , Return a DSN if delivery succeeds.
  44. ' cdoDSNSuccessFailOrDelay = 14 ,Return a DSN if delivery succeeds, fails, or is delayed.
  45. .Send ' ¶Ç°e


  46. End With
  47. Set objCDO = Nothing


  48. End Sub
½Æ»s¥N½X

¦^´_ 2# ML089

ÁÂÁÂML089¤j¤j¡A
µ{¦¡¥¿±`¥i¥H°õ¦æ¤F¡AÁÂÁÂ
    :D

TOP

¦^´_ 2# ML089

ML089¤j¤j¡G

­è­è¦bµ{¦¡½X³Ì«á­±¥[¤W
Function RangetoHTML(rng As Range)
End Function

µ{¦¡¥i¥¿±`°õ¦æ¨Ã±H°e¶l¥ó¡A
¦ý¬O¶l¥ó¤º¤å¬OªÅ¥Õ¡A¤£·|°õ¦æ¥H¤Uµ{¦¡½X:
.HTMLBody = RangetoHTML(Range("A1:J31"))

ÁÂÁÂ~

TOP

ÁÂÁ¦U¦ì¤j¤j¼ö¤ßªº¦^µª¡A·P¿E¤£ºÉ~~

¦]¬°¥²¶·­n¨Ï¥Î¤½¥q¦øªA¾¹¥D¾÷¨Ó±H°e¡A
¸Õ¹L¥ÎCDOª«¥ó±H¶l¥ó¥i¥H¦¨¥\¡C
¦ý¬O¶l¥ó±H¥X«á¡A¦³¥H¤U´X­Ó°ÝÃD«Ý¸Ñ¨M¡G
1.½Ð°Ý¥i¥H¦b.Send¶Ç°e¤§«e¥[¤W.Stop¡H¦nÅý§Ú¥i¥H·í¤U¬d¬Ý·Ç³Æ±H¥Xªº¶l¥ó¸ê®Æ¬O§_¦³»~
2.¶l¥ó±H¥X«á¡A±H¥ó³Æ¥÷¸Ì¨S¦³±H¥óªº¬ö¿ý¡A¸Ó¦p¦ó³B²z¡H
ÁÂÁÂ

TOP

        ÀR«ä¦Û¦b : ¯àµ½¥Î®É¶¡ªº¤H¡A¥²¯à´x´¤¦Û¤v§V¤Oªº¤è¦V¡C
ªð¦^¦Cªí ¤W¤@¥DÃD