我将一个从.docx转换为.pdf的文档保存到了桌面。最后一个任务是将此.pdf附加到电子邮件的正文中。 HTML签名应保持不变。
我认为问题在于这行代码,我不知道如何纠正它:
SELECT Id, Name,
MAX(CASE WHEN qname = 'q1' THEN SEQ END),
MAX(CASE WHEN qname = 'q2' THEN SEQ END),
MAX(CASE WHEN qname = 'q3 'THEN SEQ END),
MAX(CASE WHEN qname = 'q4 'THEN SEQ END)
FROM (SELECT t.*, tt.*,
DENSE_RANK() OVER (PARTITION BY t.Name ORDER BY tt.qq DESC) AS SEQ
FROM @temp t CROSS APPLY
( VALUES (q1, 'q1'), (q2, 'q2'), (q3, 'q3'), (q4, 'q4')
) tt(qq, qname)
) t
GROUP BY t.Id, t.Name;
完整代码:
.Attachments.Add PdfFile.FullName
答案 0 :(得分:0)
这可以做到:
Public Sub Mail()
Dim LastAuthor As String
Dim Email As String
Dim MyPdfName As String
Dim objDoc As Document
LastAuthor = ActiveDocument.BuiltinDocumentProperties("last Author")
Email = Replace(LastAuthor, " ", ".") & "@xyz.ro"
Set objDoc = ActiveDocument
MyPdfName = Replace(objDoc.FullName, ".docx", ".pdf")
objDoc.ExportAsFixedFormat _
OutputFileName:=MyPdfName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, Item:=wdExportDocumentContent
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Display
.To = Email
.CC = ""
.BCC = ""
.Subject = objDoc.Name
.HTMLBody = "<BODY style=font-size:12pt;font-family:Calibri>Servus<br>Esantionul este in ordine.<br><br>Multumesc,<br>" & .HTMLBody
.Attachments.Add MyPdfName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
MsgBox "E-mail trimis cu succes"
End Sub
它远非完美,但现在更加清晰了,最重要的是,可以正常工作。