views:

1667

answers:

5

Hi,

I am attempting to send an email using VB.NET.

There are two requirements

  1. The email be saved in their "Sent Items" folder in Outlook (their only email client).
  2. A PDF (generated on the fly) is attached to the email.

I am currently creating a new MailMessage & sending via a SmtpClient, but I believe that this sends from the server, and not from the client.

Is this possible?

Thanks,

EDIT: This is a winforms application, the purpose is to send reports to clients.

A: 

You'll have to use the exchange server API or have a local copy of Outlook and use the outlook client API in order to make this happen. SMTP Client and exchange really have very little to do with each other, other than the fact that the Exchange server knows what to do with an SMTP message.

You might be better off just sending two copies of the e-mail, one to the sender and one to the sendee. It's not as seemless in having it show up in the sent items, but it would be much less work and accomplish the same goal.

tom.dietrich
That's kinda what I was expecting. Thanks
Nathan Koop
+3  A: 

I think you'd need to do 1 of the following to get the exact functionality you want:

  • Outlook Interop
  • Exchange event sink

As a much easier alternative, how about BCC the user (which will get to their Inbox) and configure an Outlook rule to move it to sent items?

Mark Brackett
Faster is faster:) +1
Sunny
+1  A: 

You are right, it won't end up in the users sent items. One of the problems you are going to run into is that the very API that Outlook has to do this has been exploited by viruses and therefore the user will need to ok the send every time.

I would look into whether you can do this by talking to Exchange instead. There are API's to both scripting Outlook and talking to Exchange directly.

Lou Franco
+1  A: 

Just use the Exchange WebDav API.

Here is the Microsoft support sample on how to send an email using WebDav:Q296713

note: Sorry the sample above is for VB 6, it should be pretty straight forward to port the code to VB.NET (plus you can use the System.Xml classes and/or StringBuilder to help build the WebDav xml requests).

Coderuckus
Outlook Interop can give security warnings under outlook 2003 (and above in some cases) but this gets around that. Also the interop is unmanaged code.
John
+1  A: 

I ended up using the Outlook Interop through a class by David M Brooks on CodeProject

Nathan Koop