Here I’m looking for one function, for opening email and send new message to som...@company.com
Pls. help me. I am planning to use this function in menu file to receive error reports of my programs.
Do help me…
Regards,
Amit
(setq YN (strcase (getstring "\nAutomatically send EMAIL - [N]=No or [y]=Yes
? ")))
(if (= YN "Y")
(progn
(setq E_SENDTO (list "som...@company.com"))
(setq E_SUBJECT "Subject Message")
(setq E_BODY "Body Message")
(setq E_ATTACH (list FileName)) ; to attach file(s) to email
(vl-load-com)
(setq A_APP (vlax-get-acad-object)
A_DOC (vlax-get-property A_APP 'activedocument)
)
(if (or (= (setq O_APP (vl-catch-all-apply 'vlax-get-object (list
"Outlook.Application"))) nil) (/= (type O_APP) 'vla-object))
(progn
(alert (strcat "Microsoft Outlook must already be running to create
and send the email."
"\n\nPlease start Microsoft Outlook and then close
this dialog box to create the email."
"\n\nYou might get a message in Outlook saying
another program is trying to access Outlook."
"\n\nAnswer YES to each of the prompts to allow the
email to continue.")
)
(setq O_APP (vl-catch-all-apply 'vlax-get-object (list
"Outlook.Application")))
)
(progn
(alert (strcat "\n\nYou might get a message in Outlook saying
another program is trying to access Outlook."
"\n\nAnswer YES to each of the prompts to allow the
email to continue.")
)
)
)
(if (= (type O_APP) 'vla-object)
(if (setq MAIL_OBJ (vlax-invoke-method O_APP 'createitem 0)) ;;
Create new email object
(if (setq RECIPIENTS (vlax-get-property MAIL_OBJ 'recipients)) ;;
Get the recipients collection
(progn ;; Add the recipients properties to the email
(foreach ITEM E_SENDTO
(if (= (type ITEM) 'str)
(vlax-invoke-method RECIPIENTS 'add ITEM)
)
)
;; Add the subject properties to the email
(if (= (type E_SUBJECT) 'str)
(vlax-put-property MAIL_OBJ 'subject E_SUBJECT)
)
;; Add the body properties to the email
(if (= (type E_BODY) 'str)
(vlax-put-property MAIL_OBJ 'body E_BODY)
)
;; Add the attachements properties to the email
(if (and (vl-consp E_ATTACH) (setq ATTACHMENTS
(vlax-get-property MAIL_OBJ 'attachments)))
(foreach ITEM E_ATTACH
(if (and (setq TEMP1 (findfile ITEM)) (vl-file-systime
TEMP1))
(vlax-invoke-method ATTACHMENTS 'add TEMP1)
)
)
)
;; If the E_SENDTO, E_SUBJECT, and E_BODY were set okay then
send the email, otherwise display the email for the user to finish
(if (and (vl-consp E_SENDTO) E_SUBJECT E_BODY (/= E_SUBJECT "")
(/= E_BODY ""))
(vlax-invoke-method MAIL_OBJ 'send)
(vlax-invoke-method MAIL_OBJ 'display)
)
)
(princ "\nCould not get the recipients collection from the new
mail item")
)
(princ "\nCould not create a new mail item through Outlook")
)
(princ "\nCould not create a new instance of Outlook")
)
;; Release the objects
(if (and (= (type ATTACHMENTS) 'vla-object) (= (vlax-object-released-p
ATTACHMENTS) nil))
(vlax-release-object ATTACHMENTS)
)
(if (and (= (type RECIPIENTS) 'vla-object) (= (vlax-object-released-p
RECIPIENTS) nil))
(vlax-release-object RECIPIENTS)
)
(if (and (= (type MAIL_OBJ) 'vla-object) (= (vlax-object-released-p
MAIL_OBJ) nil))
(vlax-release-object MAIL_OBJ)
)
(if (and (= (type O_APP) 'vla-object) (= (vlax-object-released-p O_APP)
nil))
(vlax-release-object O_APP)
)
(if (and (= (type A_DOC) 'vla-object) (= (vlax-object-released-p A_DOC)
nil))
(vlax-release-object A_DOC)
)
(if (and (= (type A_APP) 'vla-object) (= (vlax-object-released-p A_APP)
nil))
(vlax-release-object A_APP)
)
)
(alert "\nNOTICE - Report NOT sent via Email.")
)
"amitvedak" <nos...@address.withheld> wrote in message
news:781920.1101718667...@jiveforum1.autodesk.com...
> Do help me.
>
> Regards,
> Amit
i hope this function will help me....
regards,
amit