473,385 Members | 1,707 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,385 software developers and data experts.

Opening an Outlook profile with VB

Hello,

I am trying to set up a program that will email me when a process has been
completed by a user. The user uses a program that moves some files, after
these files are moved I want the program to also send an email that the
process has been completed.

The PC's are set up to use outlook profiles. When a user logs into our 2000
domain server through that machine, and they open outlook they are presented
with a box to chose the correct profile. If they chose their own, their
email box opens. If they chose one that is not theirs but another users they
will not be able to open outlook.

What I want this program to do is go through and open the profile of the
current logged on user. I need to assume that the outlook client will not be
open and that the program will open the program and select the correct
profile. How can this be done? I am using the following code:

SORRY FOR THE LONG MESSAGE BUT I HOPE IT CLEARS UP ANY QUESTIONS YOU MAY
HAVE. Can someone suggest a solution?

Public Function EmailMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookNameSpace As NameSpace

'Create the Outlook Session

Set objOutlook = CreateObject("Outlook.application")
Set objOutlookNameSpace = GetNamespace("MAPI")
objOutlookNameSpace.Logon

'Create the message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
'Add the To recipient(s) to the message
Set objOutlookRecip = .Recipients.Add("da**********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("ca**********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("jo*********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("mi********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("fr************@timesnews.com")
Set objOutlookRecip = .Recipients.Add("br********@timesnews.com")
objOutlookRecip.Type = olTo

'Set the subject, body and importance of the message
.Subject = "Burt Export " & EnterDate
.Body = "The Burt Export from PBS has been completed for " & EnterDate
.Importance = olImportanceHigh

'Resolve each Recipients name
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

'Dispaly the message before sending
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function
Nov 21 '05 #1
3 8673
Paul,

This kind of questions are often asked in this newsgroup and need in my
opinion only some investigations in the given answers.

They are in this link
http://tinyurl.com/46ga8

Maybe you can check for yourself if the best answer is in those
(You see first your own question, I would advise you to look first at the
answer from Jay B.)

I hope this helps?

Cor

"Paul" <Pa**@discussions.microsoft.com> schreef in bericht
news:46**********************************@microsof t.com...
Hello,

I am trying to set up a program that will email me when a process has been
completed by a user. The user uses a program that moves some files,
after
these files are moved I want the program to also send an email that the
process has been completed.

The PC's are set up to use outlook profiles. When a user logs into our
2000
domain server through that machine, and they open outlook they are
presented
with a box to chose the correct profile. If they chose their own, their
email box opens. If they chose one that is not theirs but another users
they
will not be able to open outlook.

What I want this program to do is go through and open the profile of the
current logged on user. I need to assume that the outlook client will not
be
open and that the program will open the program and select the correct
profile. How can this be done? I am using the following code:

SORRY FOR THE LONG MESSAGE BUT I HOPE IT CLEARS UP ANY QUESTIONS YOU MAY
HAVE. Can someone suggest a solution?

Public Function EmailMessage(DisplayMsg As Boolean, Optional
AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookNameSpace As NameSpace

'Create the Outlook Session

Set objOutlook = CreateObject("Outlook.application")
Set objOutlookNameSpace = GetNamespace("MAPI")
objOutlookNameSpace.Logon

'Create the message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
'Add the To recipient(s) to the message
Set objOutlookRecip = .Recipients.Add("da**********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("ca**********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("jo*********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("mi********@timesnews.com")
Set objOutlookRecip =
.Recipients.Add("fr************@timesnews.com")
Set objOutlookRecip = .Recipients.Add("br********@timesnews.com")
objOutlookRecip.Type = olTo

'Set the subject, body and importance of the message
.Subject = "Burt Export " & EnterDate
.Body = "The Burt Export from PBS has been completed for " &
EnterDate
.Importance = olImportanceHigh

'Resolve each Recipients name
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

'Dispaly the message before sending
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function

Nov 21 '05 #2
Paul,
If you simply need to send an email, why not use the System.Web.Mail
namespace?

It does not require you reference Outlook (getting into potential version
problems).

Of course it means that the sent message will not be saved in Outlook.

The following site provides a wealth of info on using System.Web.Mail
namespace:

http://www.systemwebmail.net/

Hope this helps
Jay

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
Hello,

I am trying to set up a program that will email me when a process has been
completed by a user. The user uses a program that moves some files,
after
these files are moved I want the program to also send an email that the
process has been completed.

The PC's are set up to use outlook profiles. When a user logs into our
2000
domain server through that machine, and they open outlook they are
presented
with a box to chose the correct profile. If they chose their own, their
email box opens. If they chose one that is not theirs but another users
they
will not be able to open outlook.

What I want this program to do is go through and open the profile of the
current logged on user. I need to assume that the outlook client will not
be
open and that the program will open the program and select the correct
profile. How can this be done? I am using the following code:

SORRY FOR THE LONG MESSAGE BUT I HOPE IT CLEARS UP ANY QUESTIONS YOU MAY
HAVE. Can someone suggest a solution?

Public Function EmailMessage(DisplayMsg As Boolean, Optional
AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim objOutlookNameSpace As NameSpace

'Create the Outlook Session

Set objOutlook = CreateObject("Outlook.application")
Set objOutlookNameSpace = GetNamespace("MAPI")
objOutlookNameSpace.Logon

'Create the message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
'Add the To recipient(s) to the message
Set objOutlookRecip = .Recipients.Add("da**********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("ca**********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("jo*********@timesnews.com")
Set objOutlookRecip = .Recipients.Add("mi********@timesnews.com")
Set objOutlookRecip =
.Recipients.Add("fr************@timesnews.com")
Set objOutlookRecip = .Recipients.Add("br********@timesnews.com")
objOutlookRecip.Type = olTo

'Set the subject, body and importance of the message
.Subject = "Burt Export " & EnterDate
.Body = "The Burt Export from PBS has been completed for " &
EnterDate
.Importance = olImportanceHigh

'Resolve each Recipients name
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

'Dispaly the message before sending
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Function

Nov 21 '05 #3
Jay,

I had the idea as well that what you showed would be enough, however I got
the idea that Paul did want information from Exchange server, that was why I
showed the thread of messages.

From which I hoped you would add that.

However maybe I readed it wrong.

Cor
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bob | last post by:
I have been using "mapi" to send mail from my vb applications for some time. I am now working in vb.net. The problem I am having now is that I need the "from" address to be different than the...
1
by: srinivas | last post by:
Hi, i'm trying to retreive the appointments from different profiles of outlook. My outlook has 3 profiles created.('Sample1','Sample2','Sample3') my form contains 3 buttons.each one for each...
9
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
1
by: Tom Glasser | last post by:
I have the following code in my Access application: Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Set OutApp = CreateObject("Outlook.Application") Set OutMail =...
6
by: Manuel | last post by:
Hi, Using the PIA "Microsoft Outlook 11 Object Library". I've noticed that the Logon method of the NameSpace Object is simply ignored. My Outlook 2003 is full updated. For example if I...
5
by: Mike P | last post by:
I am trying to get at different users inboxes programmatically (see code below). It works fine, except for the fact that the logon line seems to always logon to my local account rather than...
1
by: jazeelkm | last post by:
Hi all, I am developing an windows application using C#. In that application I have to extract all the email ids stored in the contact folder of the outlook... Now I can extract the details using...
1
by: vibhavleo | last post by:
I am using the Microsoft Office 11.0 Object library to connect to outlook. My code is as follows: _ApplicationPtr application("Outlook.Application"); CComPtr<_NameSpace> ns;...
1
by: mary mathews | last post by:
Hi, I'm getting an exception while tried to retrive an outlook contact using asp.net in a console application. The exception is as follows: An unhandled exception of type...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.