0 Members and 2 Guests are viewing this topic.
(defun email () (setq olApp (vlax-get-or-create-object "Outlook.Application")) (setq objMail (vlax-invoke olApp 'CreateItem 0)) (vlax-put-property objMail 'Subject "subject here") (vlax-put-property objMail 'To "email here") ;<-----specified email (vlax-put-property objMail 'Body "message here") (vlax-invoke objMail 'Send))
This is pretty similar to what you are using (except you can add attachments). I tested it and do not get a prompt to send the mail.http://www.theswamp.org/index.php?topic=26953.msg324794#msg324794
; use (sendmail cRecip cSender cServer cUser cPass cSubject cMessage)(defun SendMail (cRecip cSender cServer cUser cPass cSubject cMessage / iMsg iConf Flds fItem) ; create our CDO object (setq iMsg (vlax-create-object "CDO.Message") iConf (vlax-create-object "CDO.Configuration") Flds (vlax-get-property iConf 'Fields) ) ; setq ; configure the settings (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/sendusing" ) ) (vlax-put-property FItem 'Value 2) (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpserver" ) ) (vlax-put-property FItem 'Value cServer) ; @@ SMTP SERVER (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) ) (vlax-put-property FItem 'Value 25) (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" ) ) (vlax-put-property FItem 'Value 5) ; smtp server timeout in seconds (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ) ) (vlax-put-property FItem 'Value 1) (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/sendusername" ) ) (vlax-put-property FItem 'Value cUser) ; @@ ACCOUNT (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/sendpassword" ) ) (vlax-put-property FItem 'Value cPass) ; @@ PASSWORD (vlax-invoke-method Flds 'Update) ; Build HTML for message body. (setq strHTML "<HTML>" strHTML (strcat strHTML "<HEAD>") strHTML (strcat strHTML "</HEAD>") strHTML (strcat strHTML "<BODY>") strHTML (strcat strHTML cMessage) strHTML (strcat strHTML "</BODY>") strHTML (strcat strHTML "</HTML>") ) ; setq ; Apply the settings to the message. (vlax-put-property iMsg 'Configuration iConf) (vlax-put-property iMsg 'To cRecip) (vlax-put-property iMsg 'From cSender); @@ FROM ADDRESS (vlax-put-property iMsg 'Subject cSubject) (vlax-put-property iMsg 'HTMLBody strHTML) (vlax-invoke-method iMsg 'Send) (vlax-release-object iMsg) (vlax-release-object iConf) (princ)) ; SendMail
Ron, on your routine, I didn't receive a prompt, but I still have to press send in the new email document, or is this supposed to happen?
Quote from: alanjt on December 08, 2010, 02:06:46 PMRon, on your routine, I didn't receive a prompt, but I still have to press send in the new email document, or is this supposed to happen?It should have just sent? What version of Outlook are you using?
;;Usage(rjp-OutlookMessage ;;email address (multiple separated by semicolon) "johndoe@nowhere.com;johndoewife@nowhere.com" ;;Subject "Test Email" ;;Attachments as a list of strings '("C:\\test\\file1.txt" "C:\\test\\file2.txt" "C:\\test\\file3.txt") ;;Text in body of email "Nothing to read here :)" ;;nil will open email to edit...T will send email in the background nil)
Quote from: ronjonp on December 08, 2010, 02:13:27 PMQuote from: alanjt on December 08, 2010, 02:06:46 PMRon, on your routine, I didn't receive a prompt, but I still have to press send in the new email document, or is this supposed to happen?It should have just sent? What version of Outlook are you using?'03 in win7
Quote from: alanjt on December 08, 2010, 02:14:26 PMQuote from: ronjonp on December 08, 2010, 02:13:27 PMQuote from: alanjt on December 08, 2010, 02:06:46 PMRon, on your routine, I didn't receive a prompt, but I still have to press send in the new email document, or is this supposed to happen?It should have just sent? What version of Outlook are you using?'03 in win7Did you specify T for the last arg?
Quote from: ronjonp on December 08, 2010, 02:18:29 PMQuote from: alanjt on December 08, 2010, 02:14:26 PMQuote from: ronjonp on December 08, 2010, 02:13:27 PMQuote from: alanjt on December 08, 2010, 02:06:46 PMRon, on your routine, I didn't receive a prompt, but I still have to press send in the new email document, or is this supposed to happen?It should have just sent? What version of Outlook are you using?'03 in win7Did you specify T for the last arg?I'm retarded - didn't even notice that. :ugly:FYI, it also gives me the warning.
after much searching the net i found this...it has to be setup to work for you with your smpt info and account name and passwords but its worth a tryas soon as I get ahold of my IT admin i will test this out but if someone else tests this out before i do report back and let us know if this worksCode: [Select]; use (sendmail cRecip cSender cServer cUser cPass cSubject cMessage)(defun SendMail (cRecip cSender cServer cUser cPass cSubject cMessage / iMsg iConf Flds fItem) ; create our CDO object (setq iMsg (vlax-create-object "CDO.Message") iConf (vlax-create-object "CDO.Configuration") Flds (vlax-get-property iConf 'Fields) ) ; setq ; configure the settings (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/sendusing" ) ) (vlax-put-property FItem 'Value 2) (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpserver" ) ) (vlax-put-property FItem 'Value cServer) ; @@ SMTP SERVER (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) ) (vlax-put-property FItem 'Value 25) (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" ) ) (vlax-put-property FItem 'Value 5) ; smtp server timeout in seconds (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ) ) (vlax-put-property FItem 'Value 1) (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/sendusername" ) ) (vlax-put-property FItem 'Value cUser) ; @@ ACCOUNT (setq fItem (vlax-get-property Flds 'Item "http://schemas.microsoft.com/cdo/configuration/sendpassword" ) ) (vlax-put-property FItem 'Value cPass) ; @@ PASSWORD (vlax-invoke-method Flds 'Update) ; Build HTML for message body. (setq strHTML "<HTML>" strHTML (strcat strHTML "<HEAD>") strHTML (strcat strHTML "</HEAD>") strHTML (strcat strHTML "<BODY>") strHTML (strcat strHTML cMessage) strHTML (strcat strHTML "</BODY>") strHTML (strcat strHTML "</HTML>") ) ; setq ; Apply the settings to the message. (vlax-put-property iMsg 'Configuration iConf) (vlax-put-property iMsg 'To cRecip) (vlax-put-property iMsg 'From cSender); @@ FROM ADDRESS (vlax-put-property iMsg 'Subject cSubject) (vlax-put-property iMsg 'HTMLBody strHTML) (vlax-invoke-method iMsg 'Send) (vlax-release-object iMsg) (vlax-release-object iConf) (princ)) ; SendMail
This works perfectly, I would like a link to where it was found though....I always try to put those in my LISP routines when I find something online.
Outlook -> Tools -> Trust Center -> Programmatic Access -> Never warn me about suspicious activity (not recommended)
Quote from: cmwade77 on December 08, 2010, 02:38:27 PMThis works perfectly, I would like a link to where it was found though....I always try to put those in my LISP routines when I find something online.http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Email/m-p/1619391can you post what you did so i can see how this works?
yes, me.try: "mail.YourDomainName" or "mail.YourCompanyName"