473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Outlook and .Net

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
5 1949
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


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 22 '05 #3
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fritz Switzer | last post by:
Can anyone provide a small snippet in C# that pulls out the Contacts in Outlook XP. I've seen a couple of examples in C++ and VB in previous newsgroup posts, but either the originals didn't work...
10
by: John | last post by:
Hi When I open a new outlook email from vb.net, sometimes outlook is very slow to appear or occasionally outlook freezes completely. I am targeting mixed office2000/xp environments so I am...
9
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
9
by: George McCullen | last post by:
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in...
3
by: John | last post by:
Hi I am trying to access outlook contacts folders and delete the contacts that do not contain a certain category value in the categories field. I have written the below code but am stuck with...
7
by: Chris Thunell | last post by:
I'm trying to loop through an exchange public folder contact list, get some information out of each item, and then put it into a vb.net datatable. I run though the code and all works fine until i...
8
by: Li Pang | last post by:
Hi, I used following codes to pass a message item from CDO to Outlook. They worked fine when I used outlook 2000, but get an error of "Specified cast is not valid." when I used Outlook 2003....
3
by: wizzbangca | last post by:
Hi everyone. Having problems with a utility I am writing for work. The previous IT Director thoughtfully allowed 3 (2000, xp, 2003) versions of outlook to be installed rather than 1. Now I need...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
4
by: Brian Hampson | last post by:
I recently upgraded to Outlook 2007 B2TR and have found that I can no longer code against MAPI.DLL It's gone :( Using C#, I used to get the MAPI session, and from that I could change the out of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.