excel - 有没有办法在电子邮件正文中提取 VBA 中的第一列值?
问题描述
我正在努力寻找一种方法来提取与找到的同一行匹配的第一列值cell.value
并将其插入到电子邮件正文中。
换句话说:如果我的工作表上有“发送”一词,它应该从第一列(“A”)的同一行中获取匹配的名称并将其放在我的文本正文中。
这可能吗?
我的代码如下
Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("F2:F100")
For Each cell In r
If cell.Value = "Send" Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Dim Machine_Code As Long
Dim Machine_Type As Long
Email_Subject = "Reminder to perform activity"
Email_Send_From = "George@JKhoney.com"
Email_Send_To = "xsoxperience@JKhoney.com"
Email_Cc = ""
Email_Body = "Dear, This is a friendly reminder. There are pending actions regarding your activities please take actions accordingly" & ". Due date on " & cell.Value & " This is an automatic e-mail with no response needed"
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.CC = Email_Cc
.Body = Email_Body
.Send
End With
End If
Next
debugs:
If Err.Description <> "" Then MsgBox Err.Description
Call email_2
End Sub
解决方案
推荐阅读
- python - 并非所有参数都在 SQL 语句中使用 - 其他资源在回答这个问题时不够清楚
- android - 在 Android Kotlin 中添加 admob 横幅/插页式广告时出现“无广告配置”
- python - 功能工具 - RollingSum
- python - Python Texttable - 每行的总宽度
- javascript - 管理多个用户的角色时如何避免速率限制?
- javascript - Thymeleaf - 在表中保存多条记录
- javascript - React-Error:重新渲染太多。React 限制渲染次数以防止无限循环
- javascript - Electron 中的多个窗口
- cypress - 如何使用 cypress 删除下载文件夹?
- maven - 使用maven构建HiBench项目失败