我知道有很多问题&关于这一点的答案,但我从来没有找到一个适合我的需求,我不知道该怎么做(我还在学习)。
我需要在按下按钮时发送自动电子邮件。我有一张像这样的表:
VID VENDOR CONTACT CAUSE ID CAUSE DESC WK INCIDENCE PLANNER
1224 FRUITY LEIA@COMPANY.COM 1 No ETA Between WK9-10 LEIA
1224 FRUITY LEIA@COMPANY.COM 2 Wrong Format Between WK9-10 LEIA
6554 BAGGS LEIA@COMPANY.COM 2 Wrong Format In WK9 LEIA
8455 GLASS LINK@COMPANY.COM 3 Missing info In WK10 LINK
我需要的是一个宏,它将读取上表,获取一个唯一的收件人列表(计划员),并发送一封电子邮件,其中包含该表可用于计划员的所有信息。
例如,对于LEIA@COMPANY.COM,电子邮件将如下所示:
TO: LEIA@COMPANY.COM
CC: ""
BCC: ""
SUBJECT: "VEN CHECK [current week]: [unique list of vendors] 'Ex, FRUITY, BAGGS"
BODY:
Hello [PLANNER], 'Ex. HEllo LEIA,
Your report was checked and the following results were found:
1. [CAUSE DESC] in [DESC] 'Ex. No ETA in FRUITY
2. [CAUSE DESC] in [DESC] 'Ex. Wrong Format in FRUITY
3. [CAUSE DESC] in [DESC] 'Ex. Wrong Format IN BAGGS
Please, follow the standard protocol to fix this issues on time for next week check up.
Any questions, contact me.
Regards,
到目前为止,我有以下内容:
Sub Send_Email()
Dim OutApp As Object
Dim OutMail As Object
Dim emailRng As Range
Dim recipient As Range
Dim contactList As String
Dim sTo() As String
Dim controlTable As ListObject
Set controlTable = Worksheets("Problems").ListObjects("TableProblem")
Set emailRng = controlTable.ListColumns("Contact").DataBodyRange
For Each recipient In emailRng
If (recipient <> "") And (InStr(contactList, recipient) = 0) Then
contactList = contactList & recipient & "|"
End If
Next recipient
If Len(contactList) > 0 Then contactList = Left(contactList, Len(contactList) - 1)
sTo = Split(contactList, "|")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
For i = LBound(sTo) To UBound(sTo)
With OutMail
.To = sTo(i)
.CC = ""
.BCC = ""
.Subject = ""
.Body =
Next i
问题:我最大的问题是如何像上面的示例一样修复邮件的正文。它不一定非常像那个,但身体应该给供应商,原因DESC和WK发生。
我不知道如何继续解决这个问题,也许有一个自定义类?到目前为止,我已经创建了具有简单属性的简单类。
正如您所看到的,我坚持创建Outlook项目。
如果您有时间并且可以帮助我,请这样做。
谢谢,