小编Baz*_*Baz的帖子

如何将String变量的值插入到最终会出现在电子邮件正文中的某些文本中?

我有一个电子表格,用于跟踪对其他部门的请求.我想要一个宏来生成并发送包含一些预定义文本和一些变量值的电子邮件.我已经有一些工作代码扫描相关的单元格并存储它们的值.

我可以生成电子邮件,我可以打印文本行,包括在主题中插入一个变量,但我似乎无法在电子邮件正文的中间插入任何变量的值.我有以下内容:

Sub IssueRequest()

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

' Selecting the last entry in column "B"

Range("B7").Select
ActiveCell.Offset(1, 0).Select
   Do While Not IsEmpty(ActiveCell)
   ActiveCell.Offset(1, 0).Select
   Loop
ActiveCell.Offset(-1, 0).Select


' Collect the unique value to insert into the subject field

Dim Subject As String
Subject = ActiveCell.Value

ActiveCell.Offset(0, 2).Select

' Collect the Part Number for use in the body of the email

Dim PartNumber As String
PartNumber = ActiveCell.Value

' Collect the Quantity …
Run Code Online (Sandbox Code Playgroud)

email variables excel vba excel-vba

1
推荐指数
1
解决办法
3万
查看次数

标签 统计

email ×1

excel ×1

excel-vba ×1

variables ×1

vba ×1