在单元格A中,我有名称,例如,约翰史密斯
在细胞B我有一个标准 - 到期/未到期。
我需要以某种方式修改下面的代码执行以下操作:
生成从小区A邮件,格式[email protected] 然后发送了电子邮件提醒,但只有唯一的电子邮件在一个电子邮件。 到目前为止,这是我:Excel VBA - 发送Outlook电子邮件
Sub SendEmail()
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Msg As String
'Create Outlook object
Set OutlookApp = New Outlook.Application
'Loop through the rows
For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeVisible)
If cell.Value Like "*@*" And _
LCase(Cells(cell.Row, "B").Value) = "Due" _
Then
EmailAddr = EmailAddr & ";" & cell.Value
End If
Next
Msg = "Please review the following message."
Subj = "This is the Subject Field"
'Create Mail Item and view before sending
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Display
End With
End Sub
我无法得到更进一步,很遗憾。任何人都可以帮助我吗?
除了@MacroMan引发的问题,你的代码看起来不错。究竟是什么问题。你没有说明你的**没有工作。 –
在A列中,我有一个姓名和姓氏列表,我不知道如何将循环(即John Smith转换为[email protected])并发送到一封电子邮件中。此外,我以某种方式需要过滤掉并发送给唯一的电子邮件,有时人重复... – warfo09
是每个公司的名称相同吗?或者是在另一个单元格或其他地方定义的? –