comcu Posted September 29, 2010 Posted September 29, 2010 Hi, Was hoping someone could helpo me. I print a lot of pdfs and email as attachements. Is their away to short cut my process by pressing the print button and have the layout automatically print to a pdf attached to an email? Would this be a vba / lisp routine or is their already a function to cope with this? Cheers Colin Quote
qball Posted September 29, 2010 Posted September 29, 2010 that would be handy in some cases. I wonder if when your email is open, that creates a temporary file. Then when you're printing from acad, you select that file as your destination. I don't think it's that simple, but it may be in the right direction. Quote
BlackBox Posted September 29, 2010 Posted September 29, 2010 Very interesting topic. I've recently had the 'itch' to automate the dissemination of my team's production tools, as a result of changes to our production directory structure. Translation - I can't save our .FAS files on a network share location, so I wanted to write a routine which automatically emails (using Outlook) everyone on my team the newly updated .FAS file(s). Different attachment, similar goal. :wink: I've not developed any code yet (I have a lot on my plate), but my first inclination is: (setq outlookApp (vlax-get-or-create-object "Outlook.Application")) I'll be watching this thread, and will post back when I have more to contribute. Cheers! Quote
BlackBox Posted September 30, 2010 Posted September 30, 2010 (edited) I would have posted back sooner, but I am out of the office all day. In short, this *should* be enough to get you started: (defun c:EMAIL (/ *error* recipient subject body attachment outlookApp mailItem recipItem attachItem) (vl-load-com) ;; Error checking (defun *error* () (if mailItem (vla-delete mailItem)) (if (and outlookApp (not (vlax-object-released-p outlookApp))) (vlax-release-object outlookApp)) (princ)) ;; Main code (if (and (setq recipient (getstring 1 "\n >> Enter Recipient Email Address: ")) (setq subject (getstring 1 "\n >> Enter Email Subject: ")) (setq body (getstring 1 "\n >> Enter Body Message: ")) (setq attachment (getstring 1 "\n >> Enter Attachment File Path: ")) (setq outlookApp (vlax-get-or-create-object "Outlook.Application"))) (progn ;; Create mail item (setq mailItem (vlax-invoke outlookApp 'createitem)) ;; Add recipient (setq recipItem (vlax-get mailItem 'recipients)) (vlax-invoke recipItem 'add recipient) ;; Add email subject (vlax-put-property mailItem 'subject subject) ;; Add body message (vlax-put-property mailItem 'body body) ;; Add attachment (if (and (findfile attachment) (setq attachItem (vlax-get mailItem 'attachments))) (vlax-invoke attachItem 'add attachment)) ;; Display email item (vlax-invoke mailItem 'display) ;; Send email item ;;(vlax-invoke mailItem 'send) [color=seagreen]; <- Uncomment this line to send[/color] ;; Release object (vlax-release-object outlookApp))) (princ)) Use the Microsoft Office ActiveX /VBA 'Object Model', or from within AutoCAD use the vlax-dump-object function to determine what other properties and methods are available. Hope this helps! Edited September 30, 2010 by BlackBox Forgot to add (vl-load-com) for others use Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.