Code Red > AutoLISP (Vanilla / Visual)

Lisp to e-mail content to helpdesk.

(1/7) > >>

Full disclosure I am on the Autodesk site with this <a href="">post</a>.

I have tried once or 100 times to edit this and I don't get the results I want.

Ideally This would autofill

1.  Subject name. (Subject)

2. Captures a dwg of the area someone is having a problem with this routine works exactly like I want it to for this portion. (attachment)

3. Then sends it to me. (To)

All my people would need to do is

Type a little explanation of what's going wrong (Body) in a window that is magically provided to them. (Scratch text file)
choose the objects they want for the dwg file.

Your Routine

Launches a mail

Attaches a dwg (GREAT!!)

Gives a Subject. ( I was able to add the file name and path to subject.)

and waits for the user to add the

to and body.

I have also looked at the post this routine referenced that adds a text file as an attachment.
would it be possible to edit the text file then  add that file in the body of the e-mail and send the file on it's way?

I know I am asking a lot and I am willing to do the work. It's just that much above the level I unserstand.

Thank you in advance.

lisp rountine.

--- Code - Auto/Visual Lisp: ---;;Call IT  (defun c:CRGhelp (/ _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 (  ;; 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))))(alert "After you choose your parts. Remember to send the file from outlook")  (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 "Autocad help: " (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))

EDIT (John): added code tags for better formatting.

Give This lisp file a try. I determined the other objects you need to fill in the email.

1) You need to fill in the global variables at the top of the LISP file with the info you want (TO Recipient, CC Recipient, Default Message). For the message - alternately you can read in a text file.
2) I don't think you can delete the file without determining if the email sent, so I added in a check to see if the email sent before deleting. If the email was discarded, the program checks the sent items count and will delete the file if it did not change.

P.S: If you want to look more into the Outlook ActiveX Methods and properties, This reference will get you started:

I should be able to get this a lot further along now.

Thank you so much for the help.


--- Quote from: on October 11, 2019, 05:08:29 PM ---
I should be able to get this a lot further along now.

Thank you so much for the help.

--- End quote ---

No problem - It was actually a fun exercise and useful learning for myself as well.  :-D

Some PCs connected directly to internet but does not have Outlook.
I am wondering, Is it able to send email without Outlook?!


[0] Message Index

[#] Next page

Go to full version