Outlook message box

Discussion in 'AutoCAD' started by Marcel Goulet, Jul 19, 2004.

  1. Hi,

    From my own menu in AutoCAD, I would like to use a lisp or vlisp program to activate an Outlook new message box with the sending address field and object field prefilled.

    Thanks.
     
    Marcel Goulet, Jul 19, 2004
    #1
  2. Marcel -

    You should be able to modify this code to suite your needs:

    (defun c:maildwgname ( / app end ml tx fl)
    (vl-load-com)
    (if (not (setq app (vlax-get-object "Outlook.Application")))
    (setq app (vlax-get-or-create-object "Outlook.Application")
    end T
    );setq
    );if

    (if app
    (progn
    (setq fl (strcat (getvar "DWGPREFIX")(getvar "DWGNAME"))
    tx (strcat "<HTML><HEAD><BODY><P>" fl "</p> <P>Click <A href=\"file://"
    (getvar "DWGPREFIX") "\">HERE</a> to open directory. </p></body></html>")
    );setq
    (setq ml (vlax-invoke-method app 'CreateItem 0))
    (vlax-put-property ml 'Subject fl)
    (vlax-put-property ml 'HTMLBody tx)
    (vlax-invoke-method ml 'Display 1)
    (if end (vlax-invoke-method app 'Quit))
    (mapcar 'vlax-release-object (list app ml))
    (gc)
    );progn
    (alert "Problem opening Outlook.")
    );if
    (princ));defun

    This simply opens a new mail item and adds the current path directory as the subject line and as a hyperlink. This works for Outlook 2002.

    Peter
     
    petersciganek, Jul 19, 2004
    #2
  3. Thanks, it works well but one thing.

    To fill the subject field, I use (vlax-put-property ..... 'Subject .....)
    To fill the body field, I use (vlax-put-property ..... 'HTMLBody .....)
    To fill the adress field, what do I have to use ?
     
    Marcel Goulet, Jul 19, 2004
    #3
  4. You need to use the 'Add method to the Recipients property of the mail i.e.:

    (vlax-invoke-method (vlax-get-property ml 'Recipients) 'Add "")

    - you may well run into security issues here though...

    Peter
     
    petersciganek, Jul 19, 2004
    #4
  5. I just find it, it's
    (vlax-put-property ml 'to "")

    Thanks alot.

    Ciao
     
    Marcel Goulet, Jul 19, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.