简体   繁体   English

使用文件夹中已保存的电子邮件模板通过excel发送带有VBA的电子邮件?

[英]Send email with VBA through excel with already saved email template in folder?

I have a list of emails in excel that I want to send a already premade email in outlook that I have saved as a templet in a folder.我在 excel 中有一个电子邮件列表,我想在 Outlook 中发送一封已经预制的电子邮件,我已将其保存为文件夹中的模板。 Instead of trying to recreate this email through VBA.而不是尝试通过 VBA 重新创建此电子邮件。 I am curious to know if I can just have the saved Outlook template be sent to each email.我很想知道是否可以将保存的 Outlook 模板发送到每封电子邮件。

Try this for the template.试试这个模板。 You likely want to pass the email and content variables to the function, but it sounds like you can use what you already got to reconfigure that part.您可能希望将 email 和 content 变量传递给函数,但听起来您可以使用已有的内容来重新配置该部分。

Sub CreateEmailfromTemplate()
    Dim obApp As Application
    Dim NewMail As Outlook.MailItem

    Set obApp = Outlook.Application
    Set NewMail = obApp.CreateItemFromTemplate("C:\directory\Template.oft")
    NewMail.Display
    With NewMail
        .To = "example@mail.com"
        .Display
    End With

    Set obApp = Nothing
    Set NewMail = Nothing
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM