By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

Outlook and .Net

P: n/a
Not sure where to post this.

At runtime, we need to be able to make sure a user is running Outlook (at
least 98 or higher) in order to send an email.

So, if a condition is met, we need to start up outlook (if it's not running)
and send an email from the logged on user's outlook account.

How do we do this?
Nov 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
This is a locally installed application that does the checking and mailing?

If so, just check the registry for the version of outlook that is installed
(or not).

After that you can just use CDO or Outlook automation but expect a security
popup to ask the user if they want to allow acces to the Outlook system.

An alternative is to used ShellExecute using MailTo (example:
http://www.smithvoice.com/simple.htm , the example has nothing to do with
VB, it's the same API call for any language). This technique will also pop
up that security prompt to the user and even if they allow it it will only
put the mail in their Outbox, the sending itself will only happen when a
Send/REceive is forced (automation could force it).

And another alternative, but not for retail apps, is to add a reference to
System.Web and Import/Use System.Web.Mail and use code along these lines:

Dim mail As New MailMessage

Try

mail.To = strToAddress
mail.From = strPermittedEmailAccount
mail.Subject = "Your new account information"

mail.BodyFormat = MailFormat.Text
mail.Body = strMyMessageBody

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1") 'basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
strEmailAccountWithPermissionsToSend)
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
[password of the email account that will do the send])

SmtpMail.SmtpServer = strSMTPServiceServerName

SmtpMail.Send(mail)

debug.writeline("sent")

Catch ex As System.Exception

throw ex

End Try

Change the variables to match your messages and use your own sending
account's address and password.

Hope that helps a bit.

Robert Smith
Kirkland, WA
www.smithvoice.com

"Greg Robinson" <gr**@cds-am.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
Not sure where to post this.

At runtime, we need to be able to make sure a user is running Outlook (at
least 98 or higher) in order to send an email.

So, if a condition is met, we need to start up outlook (if it's not
running)
and send an email from the logged on user's outlook account.

How do we do this?

Nov 22 '05 #2

P: n/a


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 22 '05 #3

P: n/a
Greg,
In addition to Robert Smith's comments.

The following site provides a good place to start on articles about using
Outlook & .NET.

http://www.microeye.com/resources/res_outlookvsnet.htm

Hope this helps
Jay
"Greg Robinson" <gr**@cds-am.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
Not sure where to post this.

At runtime, we need to be able to make sure a user is running Outlook (at
least 98 or higher) in order to send an email.

So, if a condition is met, we need to start up outlook (if it's not
running)
and send an email from the logged on user's outlook account.

How do we do this?

Nov 22 '05 #4

P: n/a

The more I have thought on this, the true requirement is, if something
happens in the application we need to send an email via the client's
machine. I am thinking we would have to go through their Outlook. That
way, if they are not connected when the email gets built it will sit in
their Outbox until they do get a connection.

I am also thinking about SMTP, though I do not know enough about this
yet.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 22 '05 #5

P: n/a
Is this for retail users or corporate clients? The answer to this will help
you narrow down the options.

The MailTo ShellExecute (or process.start) will create a message in whatever
default email client they use, just like a mailto link does on a web page.
The message will have all of it's fields filled in but the sending is up to
them (and they can get at the message and alter it manually). Even with
this limitation, this is probably the most quickly useful for retail apps
where you have no control over what the users are running.

Automating Outlook is viable to a point in a retail app. You'll have to
consider how to handle users who don't have Outlook installed (possibly
using the MailTo technique for those users) ... and you have to consider all
of the the intricacies of the various versions of Outlook that might be
installed. In a corporate setting this might be your primary choice because
in a typical corporate environment all users will most likely be on the
same version of Outlook. The downside is still that there will be that
security popup that the user must agree to before the message is added to
their outbox.

Using SMTP (CDO or it's .Net wrapper in the System.Web and System.Web.Mail
namespaces) is also a fine option for corporate deployment because you
usually know that there is a SMTP server somewhere on your internal network
and all you have to do is connect to it. The message in this case doesn't
go to the Outlook outlox and then to their SentItems folder, it gets sent
directly. You say that this is an interesting option but that you don't yet
have much experience using it... look again at the code I posted, that's the
extent of what you need to know to do the job... as long as somewhere on
your network there is a Windows 2000/2003 server running the SMTP service
(or any SMTP Service ... I use that on a project where the SMTP service is
Argosoft Mail Server, not the Windows SMTP Service, and the code that I
showed you works just fine). Additionally, that code can send an email from
outside the intranet if the mail server is accessable to the outside world
(as in most any SMTP mail server). Give that code a test using a valid email
address for the MailServer and let me know if you have any questions at all.

Here's another thought ... you can use the SMTP service without having a
permitted 'MailFrom' account password embedded in the application ... by
making a web service method that accepts the data you want to send, and on
the server the web service does that Sendmail code. Your app now just needs
to hit the web service.

As to what to do if the user isn't connected. If your app detects that it
isn't online or if it's having any difficulty connecting to the web service
you can just save off the data locally and have the app keep checking for
connectivity ... when the connection is available you do the send.

I like automation, and Outlook has a lot of fun things to automate, but if
the real goal is to just send an email and there are possibly differences in
the versions of Outlook that could be installed (or no Outlook at all), then
automating Outlook might not be the most direct path to hitting the goal.

Robert Smith
Kirkland, WA
www.smithvoice.com


"Greg Robinson" <gr**@cds-am.net> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...

The more I have thought on this, the true requirement is, if something
happens in the application we need to send an email via the client's
machine. I am thinking we would have to go through their Outlook. That
way, if they are not connected when the email gets built it will sit in
their Outbox until they do get a connection.

I am also thinking about SMTP, though I do not know enough about this
yet.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.