Я создаю шаблон Excel для пользователя бухгалтерии.
Почта будет отправлена, когда пользователь нажмет кнопку Отправить.
Почта Тело будет отображать детали в пользовательской форме Excel и утверждать, отклонять кнопки на уровне менеджера. Моя проблема в том, что когда менеджер нажимает кнопку «одобрить» или «отклонить», он связывается с формой электронной почты, но не показывает тело, как предыдущее письмо.
Это мой код VBA.
Sub mail_user()
Dim rng As Range
Dim OutApp As Object
Dim OutMail_User As Object
Dim OutMail_Approver As Object
Dim botton As String
Set rng = Nothing
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail_User = OutApp.CreateItem(0)
Set OutMail_Approver = OutApp.CreateItem(0)
Set rng = Selection.SpecialCells(xlCellTypeVisible) 'You can also use a range if you want
Set rng = Sheets("Petty Cash Log").Range("A1:H32").SpecialCells(xlCellTypeVisible)
On Error Resume Next
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
user = Range("E35").Value 'Email in excel range
approver = Range("E37").Value 'Email in excel range
On Error Resume Next
strHtml = "<html>" & "<body>" & "¡ÃسҵÃǨÊͺ¢éÍÁÙÅ" & "<br>" & "</br>" & "</body>" & "</html>"
botton_approve = "<html> & <body>" & "<a href='mailto:CF-MSG-ACC_AP_HO@auto.com?cc=CFGFIN002@ngerntidlor.com," & user & "&subject=Invoice%20test&body=Invoice%20'>approve</a>"
botton_approve = botton_approve & "</body> </html>"
botton_reject = "<html> & <body>" & "<a href='mailto:" & user & "?cc=someone@example.com," & approver & "&subject=somemessage&body=somebody'>Reject</a>"
botton_reject = botton_reject & "</body> </html>"
'Approver Review
With OutMail_Approver
.To = "manager@example.com"
.CC = "someone@example.com"
.Subject = "message"""
.HTMLBody = strHtml & RangetoHTML(rng) & botton_approve & botton_reject
.Send
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
ActiveWorkbook.CheckCompatibility = False
ActiveWorkbook.Save
End Sub
Я пробовал много решения, но они не работают.