如何使用预定义的消息随机发送电子邮件


How to send an email at random times with predefined messages?

我想要什么:

  • 随意发送电子邮件
  • 电子邮件从我写在列表中的一条信息中选择一条并发送
  • 如果可能的话,没有我的互动,在我设置好后发送电子邮件
  • 再次发生

有什么工具或应用程序可以做到这一点吗?Outlook延迟了交付,但我无法将其随机化。我曾考虑使用authotkey或php自己进行编码,但这需要我在后台运行程序,或者我需要设置服务器以在特定时间执行php文件。

如有任何帮助,我们将不胜感激。

注意: 如果没有禁止我提问,我会先创建自己的问题,针对我的情况,然后用我的个人实现自己回答。此后,我会将我的答案与OP联系起来,要求他根据自己的具体需求稍作修改

几周前,我有一个类似的目标,并使用autohotkey和blat实现了一个解决方案。等式的第一步是,你需要弄清楚如何正确地将blat与stunnel结合使用。为此,建议您先参考此链接。

我特别要求的是,每天都会收到一封带有pdf附件的电子邮件。电子邮件正文将包含文本文件中的特定文本。pdf和txt文件都在一个单独的目录中,编号为数百。这样,在一年的时间里,我每天都会读到不同的东西,收到不同的附件。

然后,我把它编译成一个exe,并使用一个时间表任务器来每天激活它。我不知道它是否可以在随机的基础上完成,但我想你可以使用autohotkey为其编写自己的任务调度程序。

下面是我的代码,您需要根据自己的具体需要进行更改。它激活stunnel,初始化blat,然后发送您的电子邮件。如果找不到互联网连接,它就会打开我电脑上的pdf文件,而不发送。

global path = "C:'Your_Personal_Directory'Downloads'blat311'full"
SetWorkingDir %path%
global pdf_dir = "'tmp"
global daily_dir = "'temp"
global tirmidhi_dir = "'tirmidhi'txt"
global faqih_dir =  "C:'Your_Personal_Directory'Downloads'Islamic-Books'Faqeehul-Ummat'split"
global thaanwi_dir = "C:'Your_Personal_Directory'Downloads'Islamic-Books'Thaanwi'split"
global pdf = "*.pdf"
global txt = "*.txt"
global docx = "*.docx"
global delim = "'"
global pdf_MaxCount = ComObjCreate("Shell.Application").NameSpace(path . pdf_dir).Items.Count
global tirmidhi_MaxCount = ComObjCreate("Shell.Application").NameSpace(path . tirmidhi_dir).Items.Count
global faqih_MaxCount = ComObjCreate("Shell.Application").NameSpace(faqih_dir).Items.Count
global thaanwi_MaxCount = ComObjCreate("Shell.Application").NameSpace(thaanwi_dir).Items.Count
global max_days = 365
global days := Retrieve_Days()
global custom_days := Retrieve_Days(true)
global ini_file = "daily_email.ini"
acrobat := "C:'Program Files'Adobe'Reader 11.0'Reader'AcroRD32.exe "
stunnel := "C:'Program Files'stunnel'stunnel.exe "
url=www.google.com
internet := true
RunWait, ping.exe %url% -n 1,, hide UseErrorlevel
If Errorlevel
{
    MsgBox, No internet Connection, try again later.
    internet := false
}
Run, %stunnel%,, hide UseErrorlevel
If Errorlevel
{
    MsgBox, Something went wrong with stunnel.
    internet := false
}
Retrieve_Days(custom_year = false) {
    current_date := A_YYYY . A_MM . A_DD
    if !custom_year
        begin_date := A_YYYY . 01 . 01
    else
        begin_date := 2013 . 08 . 17
    EnvSub, current_date, %begin_date%, days 
    If (current_date < 0)
    {
        MsgBox, Current Date yields negative.
        Exit
    }
    return current_date + 1 ; Returns days passed since begin_date
}
Retrieve_File(l_path, sub_dir = "", file_extension_search = "*.*", number = 1) {
    ;Initialize
    FileList = 
    search = %l_path%%sub_dir%'%file_extension_search%
    Loop, %search%
        FileList = %FileList%%A_LoopFileName%`n
    Sort, FileList  ; The R option sorts in reverse order. See Sort for other options.
    Loop, parse, FileList, `n
    {
        if A_LoopField =  ; Ignore the blank item at the end of the list.
            continue
        test = %A_Index%
        if (test = number)
            return l_path . sub_dir . delim . A_LoopField
    }
}
daily := retrieve_file(path, daily_dir, txt, Mod(days, max_days))
pdf_attachment := retrieve_file(path, pdf_dir, pdf, Mod(custom_days, pdf_MaxCount))
tirmidhi := retrieve_file(path, tirmidhi_dir, txt, Mod(custom_days, tirmidhi_MaxCount))
faqih_attachment := retrieve_file(faqih_dir,, pdf, Mod(custom_days, faqih_MaxCount))
thaanwi_attachment := retrieve_file(thaanwi_dir,, pdf, Mod(custom_days, thaanwi_MaxCount))
If internet
{
    runwait blat -install 127.0.0.1 "Your Name <your_email_address@gmail.com>"- - -u your_email_address@gmail.com -pwd Your_Pasword,, hide
    runwait blat %daily% -to your_email_address@gmail.com -subject "Daily Quran Reading" -attach %pdf_attachment%,, hide
    runwait blat %tirmidhi% -to your_email_address@gmail.com -subject "Daily Tirmidhi Reading",, hide
    runwait blat %daily% -to your_email_address@gmail.com -subject "Daily Akaabir Reading: Faqihul-Ummat" -attach %faqih_attachment%,, hide UseErrorlevel
    If Errorlevel
    {
        MsgBox, Something went wrong with faqih_attachment: %faqih_attachment%
        exit
    }
    runwait blat %tirmidhi% -to your_email_address@gmail.com -subject "Daily Akaabir Reading: Thaanwi" -attach %thaanwi_attachment%,, hide UseErrorlevel
    If Errorlevel
    {
        MsgBox, Something went wrong with thaanwi_attachment: %thaanwi_attachment%
        exit
    }
    Run, %stunnel% -exit,, hide UseErrorlevel
    If Errorlevel
    {
        MsgBox, Something went wrong with stunnel.
        exit
    }
}
else
{
    run notepad %daily%
    run notepad %tirmidhi%
    run %acrobat% %pdf_attachment%
    run %acrobat% %faqih_attachment%
    run %acrobat% %thaanwi_attachment%
}
return