以PDF格式发送电子邮件
全部的我在电子邮件中找到了一个非常酷的lisp例程,可以将AutoCAD绘图作为附件发送,我想知道是否可以修改它以发送PDF。
(defun c:eMail (/ _catch file outlook email)
;; Using Outlook, eMail selected object(s) in a temporary DWG file
;; Many thanks to Ron Perez (ronjonp) for the Outlook example (http://www.theswamp.org/index.php?topic=26953.msg324794#msg324794)
;; Alan J. Thompson, 03.28.11
(vl-load-com)
(defun _catch (f a) (not (vl-catch-all-error-p (vl-catch-all-apply f a))))
(if
(and
(or (ssget "_I") (prompt "\nSelect object(s) to eMail: ") (ssget))
(setq file (vl-filename-mktemp "" nil ".dwg"))
(_catch 'vla-WBlock
(list (cond (*AcadDoc*)
((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
)
file
(vla-get-activeselectionset *AcadDoc*)
)
)
(setq outlook (vlax-get-or-create-object "Outlook.Application"))
(setq email (vlax-invoke-method outlook 'CreateItem 0))
(_catch 'vlax-put (list email 'Subject (strcat "Emailing: " (vl-filename-base file) ".dwg")))
(_catch 'vlax-invoke (list (vlax-get email 'Attachments) 'Add file))
)
(progn (princ "\nOutlook active...")
(princ)
(vlax-invoke email 'Display :vlax-true)
(vl-file-delete file)
)
)
(foreach x (list email outlook) (and x (vlax-release-object x)))
(princ)
)
谢谢Brian 从提供的链接中使用ronjonp的子功能:
;; Usage:
; (rjp-OutlookMessage
;"johndoe@nowhere.com;johndoewife@nowhere.com" ;; email address (multiple separated by semicolon)
;"Test Email" ;; Subject
;'("C:\\test\\file1.txt" "C:\\test\\file2.txt" "C:\\test\\file3.txt");; Attachments as a list of strings
;"Nothing to read here :)" ;; Text in body of email
;nil ;; nil will open email to edit...T will send email in the background
; )
(defun rjp-OutlookMessage (To Subject AttachmentList Body Send / objMail objOL)
(and
(setq objOL (vlax-get-or-create-object "Outlook.Application"))
(setq objMail (vlax-invoke-method objOL 'CreateItem 0))
(progn
(vlax-put objMail 'To To)
(vlax-put objMail 'Subject Subject)
(vlax-put objMail 'Body Body)
(foreach file AttachmentList (vl-catch-all-apply 'vlax-invoke (list (vlax-get objMail 'Attachments) 'Add file)) )
(if send (vlax-invoke objMail 'Send) (vlax-invoke objMail 'Display :vlax-true) )
(vlax-release-object objOL)
(vlax-release-object objMail)
); progn
); and
(princ)
); defun rjp-OutlookMessage
我只是根据自己的喜好修改了格式。
页:
[1]