LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

send email with attachment from windows

    Hi there,

I need to send an email with programatically generated content from a LV application.

I have tried use ActiveX automation but can't seem to even open the  Outlook._Application object!

So instead I am trying to use the command line by invoking url.dll
(so this is not strictly a LV related question, just though someone may know the answer)

To create a new email, the following command works fine:

rundll32.exe url.dll,FileProtocolHandler mailto:%s  &Subject=%s &body=%s

where the %s are replaced with something sensible at runtime. This seems to work fine.

To add an attachment, either &attach or &attachment are used, however I cannot get either of these to work properly

rundll32.exe url.dll,FileProtocolHandler mailto:%s  &Subject=%s &body=%s &attachment="c:\\test.zip"   gives no joy Smiley Sad

I have tried messing around with all sorts of combinations of escape characters for the "\"s and " " "s howevero with no luck. Best case scenario is the email is generated with no attachement, worst case is Outlook (2002 SP-2) complains the command line argument is not valid and the switch is incorrect.

Any advice???
 
0 Kudos
Message 1 of 8
(5,424 Views)
Yes. Don't try to use Outlook via ActiveX. Smiley Wink

Seriously, there are easier ways:
  • Does your email server require authentication? If not, you can use the built-in LabVIEW functions in the SMTP palette.
  • Use the Internet Toolkit (though you need to buy this).
  • You can use the .NET libraries.
  • You can use the OpenG SMTP libraries. You can get a modified version that meets the no-linefeed-only-lines rule from this thread.
0 Kudos
Message 2 of 8
(5,413 Views)
I am quite sure the email server does require authentication, but anyway I only have the base edition of 7.1 which excludes the SMTP functions.
Don't really want to buy anything, this little project is just a way of saving me time (in the long run), but probably doesn't justify any expenditure.
.Net I have not tried, I will give it a whirl

OpenG is also a no-goer as I cannot install any packages using their internal downloader as the firewall/proxy settings dont seem to work properly... I have not tried this in a few months though so maybe its been fixed?

0 Kudos
Message 3 of 8
(5,409 Views)
I had to do something similar and ended up using an auto-hotkey script to actually control outlook itself, because my boss REALLY wanted the stuff in his mailbox.  This was a horrible way to do it.

I was quite happy with my previous solution, which involved putting the files themselves on an ftp server, and sending emails with links to the files via the command line.
0 Kudos
Message 4 of 8
(5,398 Views)
I'm not sure what you mean when you say you can't install using their internal downloader. Whose internal downloader? The OpenG library is a pretty easy solution. The link I gave earlier is incorrect. The correct thread is http://forums.ni.com/ni/board/message?board.id=170&message.id=220354. I had posted a 7.1 version of the library in that thread.

Do you want me to just email you the library? It's about 200K.
Message 5 of 8
(5,391 Views)
I meant using the openG commander to install the packages...

Thanks for the link, I have downloaded the library. Now I just have to figure out if I can use it with our internal MS Exchange server?

cheers!
0 Kudos
Message 6 of 8
(5,386 Views)
Ah, should have mentioned you were tyring to do it with Exchange. In that case, I retract my original statement and suggest that you look at the VI posted in this thread:

http://forums.ni.com/ni/board/message?board.id=170&message.id=92583&requireLogin=False


It should get you started. You can add attachments by writing to the "Attachments" property of the "MailItem" object.
0 Kudos
Message 7 of 8
(5,378 Views)
thanks for the link, but that VI is basically the same as the one I initially tried, however I get error message:

Error -2147312566 occurred at Error loading type library/DLL.
 in Send_Outlook_Mail.vi

immediately after the Automation Open function.

I have used this automation open sucessfully with an Excel object, however no such luck with using an Outlook object. I suspect it may be an incorrectly configured/registered installation of Outlook on my PC.


0 Kudos
Message 8 of 8
(5,336 Views)