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

0 Members and 1 Guest are viewing this topic.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9275
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: 17471
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: 9275
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: 17471
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: 17471
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: 17471
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: 17471
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: 17471
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: 17471
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.