+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Senior Member
    Discipline
    Manufacture
    BrianTFC's Discipline Details
    Occupation
    Structral Detailer
    Discipline
    Manufacture
    Using
    AutoCAD 2017
    Join Date
    Jan 2012
    Location
    Indiana
    Posts
    158

    AutoCAD Send attchement as PDF in an Email

    Registered forum members do not see this ad.

    All,

    I found the really cool lisp routine to send an AutoCAD drawing as an attachment in an Email and was wondering if it could be modified to send a PDF instead.

    Code:
    (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?to...4794#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)
    )
    Thanks Brian

  2. #2
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,161

    Default

    Registered forum members do not see this ad.

    Use ronjonp's subfunction from the provided link:
    Code:
    ;; 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
    I just modified the formatting per my own taste.

Similar Threads

  1. Send a drawing via email
    By Lithium in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 10th Aug 2013, 08:30 am
  2. Open and send email using visual lisp
    By Small Fish in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 15th Jul 2011, 03:28 pm
  3. Why my email
    By Adesu in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 26th Feb 2004, 03:21 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts