發佈於

按鍵精靈 發送 email 的 bug 解決方法

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

使用的版本是 按鍵精靈繁體版 2014.02.15453

編輯器會過濾幾個 關鍵字

  • .Bodypart.Charset
  • .To
  • .HTMLBodypart.Charset

最麻煩的是 .To  目前還沒找到方法解決,只能用 .cc 來收信。不然會完全無法設定接收。

.Bodypart.Charset  這個還有辦法解決,只要把它拿出 iMsg 的 With 外面就可以了

ex.  iMsg.Bodypart.Charset = “UTF-8”  ‘(中文要用 UTF-8 ! )

 

發信的 SMTP 也無法照範例的說明使用 Google SMTP Server, 會回應 沒有下 STARTTLS 的錯誤。

上網找了幾個免費的 SMTP Server 但是都有一些限制發廣告信的機制,以下兩個是測通過的。

另外一個是 AMAZON 的 AWS

他的限制比較多,主要就是預設只能寄信給認證過的網域或是郵件信箱,要離開沙盒 就要另外申請。



每月可發封數

每月流量限制

每小時限制最高封數

每24小時可發封數

最大發信頻率


sendpulse.com

12000

 1 TB 

50

---

---


aws.amazon.com

---

---

---

200

每秒 1 封

以下是範例程式碼:

Call Util_DEBUG_SendMailEx("中文測試")

//2016.07.05
//Workable email Function
//Create by Chris
Function Util_DEBUG_SendMailEx(seMailBody)

    Dim iCfg
    Dim iMsg 
    Set iCfg = CreateObject("CDO.Configuration")
    Set iMsg = CreateObject("CDO.Message")

    With iCfg.Fields
        '.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP SERVER "
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "寄件帳號"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "密碼"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "寄件者信箱"
        .Update
    End With
	
	//設定中文內容
	iMsg.Bodypart.Charset = "UTF-8"

    With iMsg
        .Configuration = iCfg
        '按鍵精靈 bug
        '============================
        '.To = "user@domain.com"
        '.Bodypart.Charset = "UTF-8"
        '.HTMLBodypart.Charset = "unicode"
        '============================
        .CC = "收件者信鄉"
        .Subject = "主旨"
        .TextBody = seMailBody
        .AddAttachment "附件檔案位置"
        '.AddAttachment  "可夾帶多個附件"
        .Send
    End With

    Util_DEBUG_SendMailEx = True
    '如果沒有任何錯誤信息,則表示發送成功,否則發送失敗 
    If Err Then 
        TracePrint Err
        Err.Clear 
        Util_DEBUG_SendMailEx = False 
    End If 

    Set iMsg = Nothing
    Set iCfg = Nothing

End Function 
Call Util_DEBUG_SendMailEx("中文測試")

//2016.07.05
//Workable email Function
//Create by Chris
Function Util_DEBUG_SendMailEx(seMailBody)

    Dim iCfg
    Dim iMsg 
    Set iCfg = CreateObject("CDO.Configuration")
    Set iMsg = CreateObject("CDO.Message")

    With iCfg.Fields
        '.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP SERVER "
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "寄件帳號"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "密碼"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "寄件者信箱"
        .Update
    End With
	
	//設定中文內容
	iMsg.Bodypart.Charset = "UTF-8"

    With iMsg
        .Configuration = iCfg
        '按鍵精靈 bug
        '============================
        '.To = "user@domain.com"
        '.Bodypart.Charset = "UTF-8"
        '.HTMLBodypart.Charset = "unicode"
        '============================
        .CC = "收件者信鄉"
        .Subject = "主旨"
        .TextBody = seMailBody
        .AddAttachment "附件檔案位置"
        '.AddAttachment  "可夾帶多個附件"
        .Send
    End With

    Util_DEBUG_SendMailEx = True
    '如果沒有任何錯誤信息,則表示發送成功,否則發送失敗 
    If Err Then 
        TracePrint Err
        Err.Clear 
        Util_DEBUG_SendMailEx = False 
    End If 

    Set iMsg = Nothing
    Set iCfg = Nothing

End Function 
email func