Author Topic: attach multiples with outlook  (Read 7062 times)

0 Members and 1 Guest are viewing this topic.

paul_s

  • Guest
attach multiples with outlook
« on: January 21, 2009, 09:11:06 AM »
Does anybody know thru coding if we can attached multiple files with outlook?

This is how we open outlook and attached a file..
(startapp (strcat "outlook.exe " "/a "  "P:\\Project Name\\Docs\\Document1.Doc"))


ronjonp

  • Needs a day job
  • Posts: 7527
Re: attach multiples with outlook
« Reply #1 on: January 21, 2009, 12:01:09 PM »
I can't get your example to work with even one attachment  :?
"the command line argument is not valid"

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

paul_s

  • Guest
Re: attach multiples with outlook
« Reply #2 on: January 21, 2009, 12:08:52 PM »
How about this, with "my" path to outlook.exe

(startapp (strcat "c:\\program files\\Microsoft Office\\Office12\\outlook.exe " "/a "  "P:\\Project Name\\Docs\\Document1.Doc"))

ronjonp

  • Needs a day job
  • Posts: 7527
Re: attach multiples with outlook
« Reply #3 on: January 21, 2009, 12:45:14 PM »
How about this, with "my" path to outlook.exe

(startapp (strcat "c:\\program files\\Microsoft Office\\Office12\\outlook.exe " "/a "  "P:\\Project Name\\Docs\\Document1.Doc"))


I had already tried that...but still got switch errors.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dustinthiesse

  • Guest
Re: attach multiples with outlook
« Reply #4 on: January 21, 2009, 01:06:15 PM »
How about this, with "my" path to outlook.exe

(startapp (strcat "c:\\program files\\Microsoft Office\\Office12\\outlook.exe " "/a "  "P:\\Project Name\\Docs\\Document1.Doc"))


I had already tried that...but still got switch errors.

I got it to work using this syntax     EDIT:  Just to clarify...I got the one attachment to work with this syntax.  Still working on multiples!!!

Code: [Select]
(startapp "outlook.exe" (strcat "/a" " " "path_in_quotes"))

Notes:  make sure there is a space between the switch and the path,
and if the path has any embedded spaces, you may have to literally quote it like so "\"path with spaces\""
« Last Edit: January 21, 2009, 01:18:53 PM by d-unit »

paul_s

  • Guest
Re: attach multiples with outlook
« Reply #5 on: January 21, 2009, 01:18:24 PM »
Hmmm..It works for me. The only thing I can think of is that do you have a "space" between
outlook.exe and the quotation mark?. And a space between the switch /a and the quotation mark.

....\\outlook.exe "
"/a "

ronjonp

  • Needs a day job
  • Posts: 7527
Re: attach multiples with outlook
« Reply #6 on: January 21, 2009, 01:32:08 PM »
Strange..I've tried 5 or 6 variants including the examples posted and this is what i get:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

paul_s

  • Guest
Re: attach multiples with outlook
« Reply #7 on: January 21, 2009, 01:38:14 PM »
This is exactly the error box I get too if the switch is  .."/a", instead of "/a ".

dustinthiesse

  • Guest
Re: attach multiples with outlook
« Reply #8 on: January 21, 2009, 01:49:08 PM »
May have something to do with different versions of MS Office.
I am using Outlook 2007.

paul_s

  • Guest
Re: attach multiples with outlook
« Reply #9 on: January 21, 2009, 01:59:47 PM »
I tried it both for Outlook 2003 & 2007. It works.

"c:\\program files\\Microsoft Office\\Office12\\outlook.exe "...for Outlook 2007
"c:\\program files\\Microsoft Office\\Office11\\outlook.exe "...for Outlook 2003

ronjonp

  • Needs a day job
  • Posts: 7527
Re: attach multiples with outlook
« Reply #10 on: January 21, 2009, 04:08:11 PM »
Ditched that route and came up with this  :-) ...let me know if it works for you.

Code: [Select]
;;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
)

(defun rjp-OutlookMessage
       (To Subject AttachmentList Body Send / objMail objOL)
  (if (and (setq objOL (vlax-get-or-create-object "Outlook.Application"))
   (setq objMail (vlax-invoke-method objOL 'CreateItem 0))
      )
    (progn
      (vlax-put objMail 'To To)
      (vlax-put objMail 'Subject Subject)
      (vlax-put objMail 'Body Body)
      (foreach file AttachmentList
(vl-catch-all-apply
  'vlax-invoke
  (list (vlax-get objMail 'Attachments)
'Add
file
  )
)
      )
      (if send
(vlax-invoke objMail 'Send)
(vlax-invoke objMail 'Display :vlax-true)
      )
      (vlax-release-object objOL)
      (vlax-release-object objMail)
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dustinthiesse

  • Guest
Re: attach multiples with outlook
« Reply #11 on: January 21, 2009, 04:27:49 PM »
Yeah ron, I've come to realize it's just not possible using the "startapp" command.

I found a thread on the AUGI forums that covers this.
Attached is some code from there, slightly modified to allow the selection of multiple attachments.

paul_s

  • Guest
Re: attach multiples with outlook
« Reply #12 on: January 21, 2009, 04:34:20 PM »
Ronjonp,

WOW!..It worked!!!! So short & simple.Thank you!

D-Unit,
Thank you for your post. I will study this too.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: attach multiples with outlook
« Reply #13 on: January 21, 2009, 04:40:02 PM »
Ronjonp,

WOW!..It worked!!!! So short & simple.Thank you!

D-Unit,
Thank you for your post. I will study this too.

You're welcome :) Glad to help out.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dustinthiesse

  • Guest
Re: attach multiples with outlook
« Reply #14 on: January 21, 2009, 04:46:02 PM »
Ronjonp,

WOW!..It worked!!!! So short & simple.Thank you!

D-Unit,
Thank you for your post. I will study this too.

No prob.  Don't know if I will ever use this information but it is pretty neat.
I don't think there will ever be a shortage of stuff to learn in this lisp world.