Author Topic: Lisp to e-mail content to helpdesk.  (Read 1128 times)

0 Members and 2 Guests are viewing this topic.

Lonnie

  • Mosquito
  • Posts: 17
Lisp to e-mail content to helpdesk.
« on: October 10, 2019, 04:03:30 PM »
Full disclosure I am on the Autodesk site with this <a href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-e-mail-content-to-helpdesk/td-p/9077327">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)
then
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.

Lonnie
lisp rountine.

Code - Auto/Visual Lisp: [Select]
  1. ;;Call IT
  2.  
  3.  
  4. (defun c:CRGhelp (/ _catch file outlook email)
  5.   ;; Using Outlook, eMail selected object(s) in a temporary DWG file
  6.   ;; Many thanks to Ron Perez (ronjonp) for the Outlook example (http://www.theswamp.org/index.php?topic=26953.msg324794#msg324794)
  7.   ;; Alan J. Thompson, 03.28.11
  8.  
  9.  
  10.   (defun _catch (f a) (not (vl-catch-all-error-p (vl-catch-all-apply f a))))
  11. (alert "After you choose your parts. Remember to send the file from outlook
  12. ")
  13.   (if
  14.     (and
  15.       (or (ssget "_I") (prompt "\nSelect object(s) to eMail: ") (ssget))
  16.       (setq file (vl-filename-mktemp "" nil ".dwg"))
  17.       (_catch 'vla-WBlock
  18.               (list (cond (*AcadDoc*)
  19.                           ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
  20.                     )
  21.                     file
  22.                     (vla-get-activeselectionset *AcadDoc*)
  23.               )
  24.       )
  25.       (setq outlook (vlax-get-or-create-object "Outlook.Application"))
  26.       (setq email (vlax-invoke-method outlook 'CreateItem 0))
  27.       (_catch 'vlax-put (list email 'Subject (strcat "Autocad help: " (vl-filename-base file) ".dwg")))
  28.       (_catch 'vlax-invoke (list (vlax-get email 'Attachments) 'Add file))
  29.     )
  30.      (progn (princ "\nOutlook active...")
  31.             (princ)
  32.             (vlax-invoke email 'Display :vlax-true)
  33.             (vl-file-delete file)
  34.      )
  35.   )
  36.   (foreach x (list email outlook) (and x (vlax-release-object x)))
  37.   (princ)
  38. )


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


« Last Edit: October 14, 2019, 09:37:20 AM by John Kaul (Se7en) »

PKENEWELL

  • Bull Frog
  • Posts: 228
Re: Lisp to e-mail content to helpdesk.
« Reply #1 on: October 11, 2019, 03:11:47 PM »
Give This lisp file a try. I determined the other objects you need to fill in the email.

NOTE:
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: https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem
« Last Edit: October 11, 2019, 05:02:16 PM by PKENEWELL »
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #2 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.

PKENEWELL

  • Bull Frog
  • Posts: 228
Re: Lisp to e-mail content to helpdesk.
« Reply #3 on: October 11, 2019, 05:29:35 PM »

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

Thank you so much for the help.

No problem - It was actually a fun exercise and useful learning for myself as well.  :-D
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

HasanCAD

  • Swamp Rat
  • Posts: 1308
Re: Lisp to e-mail content to helpdesk.
« Reply #4 on: October 14, 2019, 03:43:01 AM »
Some PCs connected directly to internet but does not have Outlook.
I am wondering, Is it able to send email without Outlook?!

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9277
Re: Lisp to e-mail content to helpdesk.
« Reply #5 on: October 14, 2019, 09:35:57 AM »
Some PCs connected directly to internet but does not have Outlook.
I am wondering, Is it able to send email without Outlook?!

I don't think Microsoft has built in SMTP support (Microsoft Server may though) so you need some sort of mail program.  But at any rate, you'd need a login to your exchange service. In a pinch, I used the exchange server credentials of a copier in the office to send out mail.

You could use a small command line based email program like Pine, or Mutt. So, in other words, you can display the message in a nice custom format/window and then just use the CLI email program to fire off the message.
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #6 on: October 14, 2019, 02:47:06 PM »
next problem.
Everything works great. EXCEPT Ain't there always one of those.
I added a few things in my body. One of which is a line to tell me what file they are in.

Code - Auto/Visual Lisp: [Select]
  1. *Fileset1* (strcat "Example file from" "\n" "\""(getvar "dwgprefix") (getvar "dwgname")"\"" "\nPlease tell me what's wrong")

This works until you get a space in the pathname. Once you do you break the link. As you see I tried to add quotes around the string but that did not work.
Does anyone know a way to get mail to send the whole url if it's got special characters?


Code - Auto/Visual Lisp: [Select]
  1. ;; Using Outlook, eMail selected object(s) in a temporary DWG file
  2. ;; Many thanks to Ron Perez (ronjonp) for the Outlook example (http://www.theswamp.org/index.php?topic=26953.msg324794#msg324794)
  3. ;; Alan J. Thompson, 03.28.11
  4. ;;Call IT
  5.  
  6.  
  7. ;; =========ENTER the Email Addresses Here as Strings!=================!
  8. (setq *IT-Email* "somedude.NET"
  9.       *CC-Email* "sumotherdude.NET"
  10.       *Fileset1* (strcat "Example file from" "\n" "\""(getvar "dwgprefix") (getvar "dwgname")"\"" "\nPlease tell me what's wrong")
  11. )
  12. ;;=====================================================================
  13.  
  14.  
  15. (defun c:CRGhelp (/ _catch cc file outlook email sf si ni)
  16.  
  17.  
  18.   (defun _catch (f a) (not (vl-catch-all-error-p (vl-catch-all-apply f a))))
  19.  
  20.   (alert "After you select object to mail remember to send from outlook")
  21.  
  22.   (if
  23.     (and
  24.       (or (ssget "_I") (prompt "\nSelect object(s) to eMail: ") (ssget))
  25.       (setq file (vl-filename-mktemp "" nil ".dwg") test (princ (strcat "\n" file)))
  26.       (_catch 'vla-WBlock
  27.               (list (cond (*AcadDoc*)
  28.                           ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
  29.                     )
  30.                     file
  31.                     (vla-get-activeselectionset *AcadDoc*)
  32.               )
  33.       )
  34.       (setq outlook (vlax-get-or-create-object "Outlook.Application")
  35.             sf (vl-catch-all-apply 'vlax-invoke (list (setq ns (vlax-invoke outlook 'GetNameSpace "MAPI")) 'GetDefaultFolder 5))
  36.             si (vl-catch-all-apply 'vlax-get (list (vlax-get sf 'items) 'count))
  37.       )
  38.       (setq email (vlax-invoke-method outlook 'CreateItem 0))
  39.       (_catch 'vlax-put (list email 'Subject (strcat "Autocad help: " (vl-filename-base file) ".dwg")))
  40.       (_catch 'vlax-invoke (list (vlax-get email 'Attachments) 'Add file))
  41.       (_catch 'vlax-invoke (list (vlax-get email 'Recipients) 'Add *IT-Email*))
  42.       (setq cc (vl-catch-all-apply 'vlax-invoke (list (vlax-get email 'Recipients) 'Add *CC-Email*)))
  43.       (_catch 'vlax-put (list cc 'Type 2))
  44.       (_catch 'vlax-put (list email 'Body *Fileset1* ))
  45.     )
  46.      (progn (princ "\nOutlook active...")
  47.             (princ)
  48.             (vlax-invoke email 'Display :vlax-true)
  49.             (if (= (vl-catch-all-apply 'vlax-get (list email 'Sent)) :vlax-true)
  50.                (vl-file-delete file)
  51.                (progn
  52.                    (if (= (setq ni (vl-catch-all-apply 'vlax-get (list (vlax-get sf 'items) 'count))) si)
  53.                        (vl-file-delete file); No email was added to Sent Items - go ahead and delete.
  54.                    )
  55.                )
  56.             )
  57.      )
  58.   )
  59.   (foreach x (list sf ns email outlook) (and x (vlax-release-object x)))
  60.   (princ)
  61. )
  62.  


EDIT (John): Added code tags for readability.
« Last Edit: October 14, 2019, 04:41:26 PM by John Kaul (Se7en) »

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #7 on: October 14, 2019, 02:53:18 PM »
You can replace spaces in urls with %20. If you mean a path with spaces enclose it in double quotes.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #8 on: October 14, 2019, 03:05:25 PM »
That's what I thought I was doing with the "\""
"\\DavWWWRoot\revit\revitblog\PublishingImages\New user Packet\Drawing2.dwg"

I expected it to give me just the url like it will when I type it in.
« Last Edit: October 14, 2019, 03:10:29 PM by Lonnie »

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #9 on: October 14, 2019, 05:20:23 PM »
If that's intended to be a unc path it should likely be:

"\"\\\\DavWWWRoot\\revit\\revitblog\\PublishingImages\\New user Packet\\Drawing2.dwg\""
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #10 on: October 14, 2019, 05:31:54 PM »
Some PCs connected directly to internet but does not have Outlook.
I am wondering, Is it able to send email without Outlook?!

If you know the name of your smtp server etc ...

Code: [Select]
(defun _send-email ( from to subject body attachment / :put :eval :main )

    ;;  see: https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2003/ms877946(v=exchg.65)

    ;;  (_send-email
    ;;      "ice-queen@hiding-at-undisclosed-location.com"
    ;;      "agent-orange@deranged-and-dangerous.com"
    ;;      "I had a wonderful dream of the single life ..."
    ;;      "... only to wake and find I was still with you IRL.\n\nOMG."
    ;;      "c:\\picture-of-large-soured-pumpkin.png"
    ;;  )
   
    (setq :eval
        (lambda ( statement )
            (vl-catch-all-apply 'eval
                (list statement)
            )
        )
    )

    (setq :put
        (lambda ( object key value / result )
            (:eval
               '(progn
                    (setq result
                        (vlax-put-property
                            (vlax-get-property object 'item key)
                           'value
                            value
                        )
                    )
                    (if result result t)
                )
            )
        )
    )
   
    (defun :main ( from to subject body attach / server-name server-port using-port cdo server result path )

        (setq
            server-name "mail.your-legit-server.com"
            server-port 25
            using-port  2
            cdo         (vlax-create-object "CDO.Message")
            server      (vlax-get-property (vlax-get-property cdo 'configuration) 'fields)
        )

        (:eval

           '(progn

                (:put server "http://schemas.microsoft.com/cdo/configuration/sendusing"      using-port)
                (:put server "http://schemas.microsoft.com/cdo/configuration/smtpserver"     server-name)
                (:put server "http://schemas.microsoft.com/cdo/configuration/smtpserverport" server-port)

                (vlax-invoke server 'update)
                (vlax-put-property cdo 'from     from)
                (vlax-put-property cdo 'to       to)
                (vlax-put-property cdo 'subject  subject)
                (vlax-put-property cdo 'textbody body)

                (and
                    (eq 'str (type attach))
                    (setq path (findfile attach))
                    (:eval '(vlax-invoke cdo 'addattachment attach))
                )

                (setq result (vlax-invoke cdo 'send))
                (setq result (if result result t))
            )
        )

        (:eval '(vlax-release-object server))
        (:eval '(vlax-release-object cdo))

        result
       
    )
   
    (:main from to subject body attachment)       

)
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #11 on: October 14, 2019, 06:12:28 PM »
That will still break on that first space. I've triad quite a few different approaches including file:/// nothing will work html and plain text.

It's a little harder than I thought. I can make it plain text then copy paste it to my autocad. That's not a bad solution.
Thanks for all the help everyone.!!!
this place is great. I promise I will return more than once every 2 years.

If that's intended to be a unc path it should likely be:

"\"\\\\DavWWWRoot\\revit\\revitblog\\PublishingImages\\New user Packet\\Drawing2.dwg\""
« Last Edit: October 14, 2019, 06:15:35 PM by Lonnie »

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #12 on: October 14, 2019, 06:24:00 PM »
It will or it did?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #13 on: October 14, 2019, 06:51:58 PM »
did sorry.

I should modify the "Did not work" a little what you had will work may work for my example.
I reality I am getting the unc from "dwgprefix"  "dwgname". That's what did not work.  For every try I did something else seemed to happen.

I am extremely happy with these results. Thank you all.

« Last Edit: October 14, 2019, 07:01:08 PM by Lonnie »

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #14 on: October 14, 2019, 08:34:34 PM »
If you're getting the path-name from dwgprefix and dwgname I'd be surprised this wouldn't work:

Code: [Select]
(defun _get-my-full-name ( )
    (   (lambda ( fn )
            (if (wcmatch fn "* *")
                (strcat "\"" fn "\"")
                fn
            )               
        )
        (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))
    )
)

What does (_get-my-full-name) return on your machine?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9277
Re: Lisp to e-mail content to helpdesk.
« Reply #15 on: October 15, 2019, 09:39:38 AM »
...
If you know the name of your smtp server etc ...

Code - Auto/Visual Lisp: [Select]
  1. ...
  2.         (setq
  3.             server-name "mail.your-legit-server.com"
  4.             server-port 25
  5.             using-port  2
  6.             cdo         (vlax-create-object "CDO.Message")
  7.             server      (vlax-get-property (vlax-get-property cdo 'configuration) 'fields)
  8.         )
  9. ...

Question: does port 25 still work (I mean, I thought port 25 was blocked now-a-days)? Good if it does, I guess.
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #16 on: October 15, 2019, 12:52:23 PM »
I will try your suggestion when I have time. That won't be today.

As a hmmm thing not a look at and interpret thing.
This is what you get when you look at the html string that gets sent with the original suggestion.

Note it's not what mine looks like when I send it. It's how outlook is interpreting it on the received side.


MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #17 on: October 15, 2019, 01:03:05 PM »
Question: does port 25 still work (I mean, I thought port 25 was blocked now-a-days)? Good if it does, I guess.

I've been successfully using the code I posted for years - it's still in place, functioning. That said, it really depends upon your mail server - recommend one talks to their IT folks for the sendusing, smtpserver & smtpserverport configuration values (lines 52-54 in the code I posted).

This is what you get when you look at the html string that gets sent with the original suggestion.

Good gawd, yet another reason NOT to use outlook. That is horrendous, polluted <expletive deleted>.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9277
Re: Lisp to e-mail content to helpdesk.
« Reply #18 on: October 15, 2019, 01:17:41 PM »
Question: does port 25 still work (I mean, I thought port 25 was blocked now-a-days)? Good if it does, I guess.

I've been successfully using the code I posted for years - it's still in place, functioning. That said, it really depends upon your mail server - recommend one talks to their IT folks for the sendusing, smtpserver & smtpserverport configuration values (lines 52-54 in the code I posted).

This is what you get when you look at the html string that gets sent with the original suggestion.

Good gawd, yet another reason NOT to use outlook. That is horrendous, polluted sh@t.

Oh, I'm not questioning the code (I'm sure it works) but I was just questioning port 25. I know a lot of ISPs here, in the states, block 25 for client to server communications ('cutting down on spam" and all of that stuff). In the US, and/if I understand the scenario properly--doubtful--25 is only used now-a-days in between servers; client side communications are supposed to use TSL (587). If 25 works, great.

Yeah, that's outlook/html email for you; messy stuff. :) You can change your settings to Plain text and get cleaner results.
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #19 on: October 15, 2019, 01:42:41 PM »
I was just questioning port 25.

That’s how I read it.

Yeah, that's outlook/html email for you; messy stuff. :) You can change your settings to Plain text and get cleaner results.

Or just eschew that route entirely.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #20 on: October 15, 2019, 01:45:36 PM »
I am just a small cog in a big company. I don't get to choose how people send or receive mail. It's outlook and they get to choose html or plain text.  :2funny:

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #21 on: October 15, 2019, 01:48:04 PM »
How users read mail is out of your hands. How you send it is in your hands.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #22 on: October 15, 2019, 01:58:17 PM »
True for how I send it.

As you've hooked me into playing. Here is what it came back with

Command: (_get-my-full-name)
"C:\\Users\\lshaw\\Documents\\Drawing1.dwg"

Mail did not work too well but that could have been my mistake. (Ok it was my mistake.) I will see what comes out.


MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #23 on: October 15, 2019, 02:00:56 PM »
"C:\\Users\\lshaw\\Documents\\Drawing1.dwg"

That's for a dwg that hasn't been saved. What about a drawing that resides within the unc path you indicated earlier?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #24 on: October 15, 2019, 02:06:10 PM »
 :uglystupid2: You're so picky. GD&R (Grin Duck and Run.)

Command: (_get-my-full-name)
"\"\\\\dce\\boi\\Projects\\2018 Jobs\\18PAC01 - Garden Brook Senior Village - Garden Grove, CA\\Cadd\\Apartments\\18PAC01-M215.dwg\""

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #25 on: October 15, 2019, 02:17:41 PM »
You're so picky.

:uglystupid2: You're so vague.

- Carly Simon.

"\"\\\\dce\\boi\\Projects\\2018 Jobs\\18PAC01 - Garden Brook Senior Village - Garden Grove, CA\\Cadd\\Apartments\\18PAC01-M215.dwg\""

Should work.

What does (findfile (_get-my-full-name)) return?

What does (findfile (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))) return?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #26 on: October 15, 2019, 02:21:58 PM »
Command: (findfile (_get-my-full-name))
"\\\\dce\\Projects\\2019\\19DUP01 - Dupont GWP Upgrade\\Cadd\\19DUP01_mpx-model.dwg"

Command: (findfile (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname))))
"\\\\dce\\Projects\\2019\\19DUP01 - Dupont GWP Upgrade\\Cadd\\19DUP01_mpx-model.dwg"

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #27 on: October 15, 2019, 02:49:15 PM »
That result suggests the following should work provided you know the appropriate smtp values to code into the _send-email function:

Code: [Select]
(_send-email                      ;; see pickey email thread: http://bit.ly/2BfbU2g
    (_get-users-email-addy)       ;; do-able via active directory
    (_get-help-desk-email-addy)   ;; a constant you would provide
    (_get-email-subject)          ;; either hard coded or via some input method
    (_get-email-body)             ;; either hard coded or via some input method
    (_get-my-full-name)           ;; see pickey email thread: http://bit.ly/2BfbU2g
)

« Last Edit: October 15, 2019, 03:02:49 PM by MP »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #28 on: October 17, 2019, 09:22:40 AM »
Regarding _get-users-email-addy the following should work (I say should because I just translated it from vb and I'm not on an active directory network at home so I can't test it). Would be great if someone could verify if it works or not, thanks.

Code: [Select]
(defun _get-users-email-addy ( / network user domain conn qry ldaprs fld result )
    (vl-catch-all-apply
       '(lambda ( )
            (setq
                network (vlax-create-object "Wscript.Network")
                user    (vlax-get network 'username)
                domain  (vlax-get network 'userdomain)
                conn    (vlax-create-object "ADODB.Connection")
            )
            (vlax-put conn 'provider "ADsDSOObject")
            (vlax-invoke conn 'open "ADSI")
            (setq
                qry    (strcat "select mail from 'LDAP://" domain "' ")
                qry    (strcat qry "WHERE objectClass = 'user' and ")
                qry    (strcat qry "samAccountName = '" user "'")
                ldaprs (vlax-invoke conn 'execute qry)
                fld    (vlax-invoke (vlax-get ldaprs 'fields) 'item "mail")
                result (vlax-get fld 'value)
            )
        )
    )
    (vl-catch-all-apply 'vlax-release-object (list fld))
    (vl-catch-all-apply 'vlax-release-object (list ldaprs))
    (vl-catch-all-apply 'vlax-release-object (list conn))
    (vl-catch-all-apply 'vlax-release-object (list network))
    (if (eq 'str (type result)) result)
)

(_get-users-email-addy) >> yourname@yourdomain.com

Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Lonnie

  • Mosquito
  • Posts: 17
Re: Lisp to e-mail content to helpdesk.
« Reply #29 on: October 17, 2019, 01:19:20 PM »
I think I'm good for now.

lisp is in committee and we'll see what type of camel (Ol' saw. A camel is a horse designed by committee.) comes out. I've already had to cut it down and change words (Sigh).


Once again You've all been great. I hope I can contribute later on and answer someone's question. I've been doing it for a few years (I started before oops was a lisp routine.)  and know a few tricks.


MP

  • Seagull
  • Posts: 17479
Re: Lisp to e-mail content to helpdesk.
« Reply #30 on: October 17, 2019, 09:54:38 PM »
If the horse proposal has been submitted to a committee expect they’ll want a hippogriff for the price of a thumbelina.

An aside, I did a quick test of _get-users-email-addy on an active directory based network today and it works. Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox