VBA生成200封电子邮件 [英] VBA to generate 200 emails

查看:84
本文介绍了VBA生成200封电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在尝试编写一个生成大约200封电子邮件的程序。代码的框架应如下所示:

I am trying to write a procedure which generates around 200 emails. The skeleton of the code should look something like this:

Dim MName, MEmail, MCat, MLt As Variant
Dim NoMfg As Integer


' MName = name of the company
MName = Cells("a1:a200")

' MEmail = email address of the company
MEmail = Cells("b1:b200")

' MLt = Sales of the company
MLt = Cells("c1:c200")


Dim myItem As Object
Set myItem = Application.createitem(olMailItem)

with myItem

这就是我被困住的地方。我需要VBA来生成类似于以下内容的电子邮件:

And here is where I'm stuck. I need VBA to generate email which looks something like:

" Hello +" MName" ,

您的销售额为+"MLt" _"

这有意义吗?

想法?

推荐答案

Sub EmailNow()

    Dim ol As Object

    Dim myItem As Outlook.MailItem

    Dim myMsg As String

    Dim MName As Range

    Dim myC As Range



   设置ol = CreateObject(" outlook.application")

   设置MName =范围("A1:A200"))


   对于每个myC In MName

        myMsg =" Hello," &安培; myC.Value& "," &安培; Chr(10)

        myMsg = myMsg& "您的销售是" &安培;格式(myC.Offset(0,2).Value,"
Sub EmailNow()
    Dim ol As Object
    Dim myItem As Outlook.MailItem
    Dim myMsg As String
    Dim MName As Range
    Dim myC As Range

    Set ol = CreateObject("outlook.application")
    Set MName = Range("A1:A200")

    For Each myC In MName
        myMsg = "Hello," & myC.Value & "," & Chr(10)
        myMsg = myMsg & "Your sales are " & Format(myC.Offset(0, 2).Value, "


#,###。00")& "。" &安培; Chr(10)

        myMsg = myMsg& "最诚挚的问候", &安培; Chr(10)

        myMsg = myMsg& "Ammasel"



       设置myItem = ol.CreateItem(olMailItem)

        myItem.to = myC.Offset(0,1).Value

        myItem.Subject ="电子邮件主题"

        myItem.Body = myMsg

        myItem.Send



   下一页myC

   设置ol = Nothing



结束子
#,###.00") & "." & Chr(10)
        myMsg = myMsg & "Best Regards," & Chr(10)
        myMsg = myMsg & "Ammasel"

        Set myItem = ol.CreateItem(olMailItem)
        myItem.to = myC.Offset(0, 1).Value
        myItem.Subject = "Subject of email"
        myItem.Body = myMsg
        myItem.Send

    Next myC
    Set ol = Nothing

End Sub


这篇关于VBA生成200封电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆