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

[µo°Ý] Àɮפ¤ªº¨â­ÓSheet ½Æ»s¨ì·sªºÀÉ®×°ÝÃD

¦^´_  GBKEE
¦^ÂÐGBKEE: ­«·s¦bÀˬd´ú¸Õ¨ä¥LÀÉ®×,³£¤£¦æ½Æ»s¤T­Ó¥H¤Wªºsheet!  Sheets(Array("TEST", "RA ...
jackyliu µoªí©ó 2013-8-28 15:30

ªþ¤WÀɮסA½Ð°Ñ¦Ò¡G
¼Ï¯Ã¾ã²z§¹²¦«á½Æ»s¨ì·sªºÀÉ®×°ÝÃD.rar (20.46 KB)

TOP

¦^´_ 11# c_c_lai
·PÁÂc_c_lai ,¤j¤OÀ°¦£ ! ½Æ»s·sÀɮק¹¦¨,¨S°ÝÃD¤F
­Y±N¨Ì¤é´Á®É¶¡²£¥ÍªºÀÉ®×,­nmail¥X¥h,
§Ú¤§«e³£¬O¤@ª½«ü©w¦P¤@­ÓÀÉ®×,¦ý¥Ø«e°µªk¬O­n±N
­è¤~²£¥Íªºmail¥X¥h,¥i§_«ü¾É¤@¤U !

§Ú¤§«eªþ¥ó¼gªk¦p¤U: ¤£ª¾¹D­n¦p¦ó ±N­è²£¥ÍªºªºÀÉ®×,­nmail¥X¥h(¤é´Á®É¶¡©R¦WÀÉ®×)
CDO_Mail_Object.AddAttachment "D:\TEMP\test.xls"

TOP

¦^´_ 12# jackyliu
¦³Ãö Send Mail Using CDO¡A§Ú±q°ê¥~ºô¯¸ºK¿ý¤F¤@½g¡A½Ð°Ñ¦Ò¡G
  1. ' Send Mail Using CDO
  2. Public Sub testCDO()
  3. '  Purpose   Demondtrate Sending an Email with an attachment using CDO (Collaboration Data Objects)
  4. '           Uses Late Binding - Does not need a reference to the Microsoft CDO For Windows library
  5. '           cdosys comes innstalled as standard on Windows 2K and higher workstations and servers
  6. '           This code will fail on NT4, Win 98, and Win 95 where the cdosys.dll is not present
  7. '  Author    Ron Weiner    [email protected]
  8. '           Copyrite © 2004-2005 WorksRite Software Solutions
  9. '           You may use this code example for any purpose what-so-ever with
  10. '           acknowledgement. However, you may not publish the code without
  11. '           the express, written permission of the author.
  12.     Const cdoSendUsingPort = 2
  13.     Const cdoBasic = 1
  14.     Dim objCDOConfig As Object, objCDOMessage As Object
  15.     Dim strSch As String

  16.     strSch = "http://schemas.microsoft.com/cdo/configuration/"
  17.     Set objCDOConfig = CreateObject("CDO.Configuration")
  18.     With objCDOConfig.Fields
  19.         .Item(strSch & "sendusing") = cdoSendUsingPort
  20.         .Item(strSch & "smtpserver") = "SMTP.ServerName.Com"
  21.         ' Only used if SMTP server requires Authentication
  22.         .Item(strSch & "smtpauthenticate") = cdoBasic
  23.         .Item(strSch & "sendusername") = "[email protected]"
  24.         .Item(strSch & "sendpassword") = "YourPassword"
  25.         .Update
  26.     End With

  27.     Set objCDOMessage = CreateObject("CDO.Message")
  28.     With objCDOMessage
  29.         Set .Configuration = objCDOConfig
  30.         .from = "Senders Pretty Name"
  31.         .sender = "[email protected]"
  32.         .To = "[email protected]"
  33.         .Subject = "Sample CDO Message"
  34.         ' Use TextBody to send Email in Plain Text Format
  35.         '.TextBody = "This is a test for CDO message"
  36.         ' Use HTMLBody to send Email in Rich Text (HTML) Format
  37.         .HTMLBody = "Test CDO Rich Text this is not Bold But <B>This is!</B>"
  38.         ' Adding Attachments is easy enough
  39.         .AddAttachment "c:\SomeFile.zip"
  40.         .AddAttachment "c:\SomeOtherFile.pdf"
  41.         ' Un-Rem next line to get "Return Reciept Request"
  42.         '.MDNRequested = True
  43.         .Send
  44.     End With
  45.     Set objCDOMessage = Nothing
  46.     Set objCDOConfig = Nothing
  47. End Sub
½Æ»s¥N½X

TOP

¦^´_ 13# c_c_lai

§Ú¦b·Qfs±o¨ì·sÀɮצWºÙ©M¸ô®| , ±N¦¹°T®§µ¹ Sub sendmail()°Æµ{¦¡, Sub sendmail()°Æµ{¦¡´N¥i¥Hªþ¥[Àɮפ覡,mail¥X¥h¤F....
Sub main()
fs = ThisWorkbook.Path & "\" & Format(Now, "yyyy_mm_dd hhmm") & ".xls"  '¦sÀÉÀɦW
End Sub

Sub sendmail()°Æµ{¦¡,³o¸Ì¤@ª½¬O¤£¥X¨Ó,­n¦p¦óªþ¥[·s«Ø¥ßªºÀÉ®×(ÀɦW¬°yyyy_mm_dd hhmm.xls)
CDO_Mail_Object.AddAttachment "D:\TEMP\test.xls" ³o¬O§Ú¤§«e«ü©w¦P¤@­ÓÀɮתº¤è¦¡,¤£ª¾¹D­n«ç»ò§ï
End Sub

¥H¤W, ½ÐªO¤j¨ó§U !

TOP

¦^´_ 14# jackyliu
³o¬O©p©Ò­nªº¶Ü¡H
  1. Sub Ex()
  2.     Dim fs As String
  3.    
  4.     fs = ThisWorkbook.Path & "\" & Format(Now, "yyyy_mm_dd hhmm") & ".xls"  
  5.     sendmail(fs)
  6. End Sub

  7. Sub sendmail(fs As String)
  8.    CDO_Mail_Object.AddAttachment fs
  9.     CDO_Mail_Object.Send
  10. End Sub
½Æ»s¥N½X

TOP

¦^´_ 14# jackyliu
¦]¬°µLªk±o¨ì SMTP Server ªº¦ì§}¡A§Ú§â°õ¦æµ²ªG¦C¥Ü¦p¤U¡C
¤§«e©p¬O¦p¦ó¶Ç°e¥X¥h¡H¯à§_§â­ì½Z¤W¶Ç´£¨Ñ¹ê°ÈÀ³¥Î¡C

¼Ï¯Ã¾ã²z§¹²¦«á½Æ»s¨ì·sªºÀÉ®×°ÝÃD.rar (24.06 KB)

TOP

¦^´_ 14# jackyliu
¦A­×¥¿«á³sµ²²£¥Íªº°T®§¡G(¤w¸g¥[¤JcdoSendUsingPort µ¥°Ñ¼Æ)
ÃöÁä©ÊÀ³¬OµLªk¥¿½T³sµ² SMTP Server¡C
  1. Sub sendEMail(fd As String)
  2.     Const cdoSendUsingPort = 2
  3.     Const cdoBasic = 1
  4.     Dim objEmail As Object, CDO_Config As Object
  5.     Dim SMTP_Config As Variant
  6.     Dim strSch As String

  7.     strSch = "http://schemas.microsoft.com/cdo/configuration/"
  8.     Set objEmail = CreateObject("CDO.Message")       '  «Ø¥ß CDO ª«¥ó
  9.    
  10.     On Error GoTo debugErr
  11.     Set CDO_Config = CreateObject("CDO.Configuration")
  12.     With CDO_Config.Fields
  13.         .Item(strSch & "sendusing") = cdoSendUsingPort
  14.         .Item(strSch & "smtpserver") = "SMTP.ServerName.Com"
  15.         ' Only used if SMTP server requires Authentication
  16.         .Item(strSch & "smtpauthenticate") = cdoBasic
  17.         .Item(strSch & "sendusername") = "[email protected]"
  18.         .Item(strSch & "sendpassword") = ""
  19.         .Update
  20.     End With

  21.     With objEmail
  22.         Set .Configuration = CDO_Config

  23.         .From = "[email protected]"               '  ±H¥óªÌ¡]ºô°ì¥²¶·¦s¦b¡^
  24.         .To = "[email protected]"                 '  ¦¬¥óªÌ
  25.         .Subject = "CDO¶l¥ó´ú¸Õ"                    '  ¶l¥ó¥D¦®
  26.         .TextBody = "¶l¥ó´ú¸Õ¥»¤å"                 '  ¶l¥ó¤º¤å
  27.    
  28.         .AddAttachment fd
  29.         .Send
  30.     End With
  31.    
  32. debugErr:
  33.     If Err.Description <> "" Then MsgBox Err.Description
  34.     Set objEmail = Nothing
  35.     Set CDO_Config = Nothing
  36. End Sub
½Æ»s¥N½X

TOP

¦^´_ 17# c_c_lai

§Ú¹J¨ì·s½Æ»ssheetªºÀɮ׶W¹L25mb, mailµo¤£¥X¥h...
ÁÙ¦b·Q¦³¨ä¥L¤è¦¡¶Ü?

¥t¥~¤À¨É§Úªºcode
Sub sendmail(fs As String)
Dim CDO_Mail_Object As Object
Dim CDO_Config As Object
Dim SMTP_Config As Variant
Dim Email_Subject, Email_Send_From, Email_Send_To, Email_Cc, Email_Bcc, Email_Body As String
Email_Subject = "Today IB Bank List! (Attachment)"
Email_Send_From = "[email protected]"
Email_Send_To = "[email protected]"
Email_Cc = "[email protected]"
Email_Bcc = "[email protected]"
Email_Body = "test "
Set CDO_Mail_Object = CreateObject("CDO.Message")
On Error GoTo debugs
Set CDO_Config = CreateObject("CDO.Configuration")
CDO_Config.Load -1
Set SMTP_Config = CDO_Config.Fields
With SMTP_Config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'please put your server name below
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxxx.xxx.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With CDO_Mail_Object
Set .Configuration = CDO_Config
End With
CDO_Mail_Object.Subject = Email_Subject
CDO_Mail_Object.From = Email_Send_From
CDO_Mail_Object.To = Email_Send_To
CDO_Mail_Object.TextBody = Email_Body
CDO_Mail_Object.CC = Email_Cc 'Use if needed
CDO_Mail_Object.BCC = Email_Bcc 'Use if needed
CDO_Mail_Object.AddAttachment "D:\test.xls"


CDO_Mail_Object.Send
debugs:
If Err.Description <> "" Then MsgBox Err.Description
'Sheet1.Select
ThisWorkbook.Save
Application.DisplayAlerts = True
ThisWorkbook.Close
End Sub

TOP

¦^´_ 18# jackyliu
©pªº SMTP Server ªº IP Address ¬O³]©w¦h¤Ö¡H

TOP

¦^´_ 19# c_c_lai

.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'please put your server name below
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxxx.xxx.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

TOP

        ÀR«ä¦Û¦b : ­n¥Î¤ß¡A¤£­n¾Þ¤ß¡B·Ð¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD