I should be able to get this a lot further along now.
Thank you so much for the help.
Some PCs connected directly to internet but does not have Outlook.
I am wondering, Is it able to send email without Outlook?!
Some PCs connected directly to internet but does not have Outlook.
I am wondering, Is it able to send email without Outlook?!
(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)
)
If that's intended to be a unc path it should likely be:
"\"\\\\DavWWWRoot\\revit\\revitblog\\PublishingImages\\New user Packet\\Drawing2.dwg\""
(defun _get-my-full-name ( )
( (lambda ( fn )
(if (wcmatch fn "* *")
(strcat "\"" fn "\"")
fn
)
)
(apply 'strcat (mapcar 'getvar '(dwgprefix dwgname)))
)
)
...
If you know the name of your smtp server etc ...Code - Auto/Visual Lisp: [Select]
... (setq server-name "mail.your-legit-server.com" server-port 25 using-port 2 ) ...
Question: does port 25 still work (I mean, I thought port 25 was blocked now-a-days)? Good if it does, I guess.
This is what you get when you look at the html string that gets sent with the original suggestion.
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.
I was just questioning port 25.
Yeah, that's outlook/html email for you; messy stuff. :) You can change your settings to Plain text and get cleaner results.
"C:\\Users\\lshaw\\Documents\\Drawing1.dwg"
You're so picky.
"\"\\\\dce\\boi\\Projects\\2018 Jobs\\18PAC01 - Garden Brook Senior Village - Garden Grove, CA\\Cadd\\Apartments\\18PAC01-M215.dwg\""
(_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
)
(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)
)
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.