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

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: Lisp to e-mail content to helpdesk.
« Reply #31 on: February 09, 2024, 03:43:46 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.

why doesn't it work for me?