473,607 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Di splayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Applica tion
Dim objOutlookMsg As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt
Dim objOutlookAttac h As Outlook.Attachm ent
Dim objOutlookNameS pace As NameSpace

'Create the Outlook Session

Set objOutlook = CreateObject("O utlook.applicat ion")
Set objOutlookNameS pace = GetNamespace("M API")
objOutlookNameS pace.Logon

'Create the message
Set objOutlookMsg = objOutlook.Crea teItem(olMailIt em)

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*********@t imesnews.com")
Set objOutlookRecip = .Recipients.Add ("mi********@ti mesnews.com")
Set objOutlookRecip = .Recipients.Add ("fr*********** *@timesnews.com ")
Set objOutlookRecip = .Recipients.Add ("br********@ti mesnews.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 = olImportanceHig h

'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 8685
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**@discussio ns.microsoft.co m> schreef in bericht
news:46******** *************** ***********@mic rosoft.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(Di splayMsg As Boolean, Optional
AttachmentPath)
Dim objOutlook As Outlook.Applica tion
Dim objOutlookMsg As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt
Dim objOutlookAttac h As Outlook.Attachm ent
Dim objOutlookNameS pace As NameSpace

'Create the Outlook Session

Set objOutlook = CreateObject("O utlook.applicat ion")
Set objOutlookNameS pace = GetNamespace("M API")
objOutlookNameS pace.Logon

'Create the message
Set objOutlookMsg = objOutlook.Crea teItem(olMailIt em)

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*********@t imesnews.com")
Set objOutlookRecip = .Recipients.Add ("mi********@ti mesnews.com")
Set objOutlookRecip =
.Recipients.Add ("fr*********** *@timesnews.com ")
Set objOutlookRecip = .Recipients.Add ("br********@ti mesnews.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 = olImportanceHig h

'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**@discussio ns.microsoft.co m> wrote in message
news:46******** *************** ***********@mic rosoft.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(Di splayMsg As Boolean, Optional
AttachmentPath)
Dim objOutlook As Outlook.Applica tion
Dim objOutlookMsg As Outlook.MailIte m
Dim objOutlookRecip As Outlook.Recipie nt
Dim objOutlookAttac h As Outlook.Attachm ent
Dim objOutlookNameS pace As NameSpace

'Create the Outlook Session

Set objOutlook = CreateObject("O utlook.applicat ion")
Set objOutlookNameS pace = GetNamespace("M API")
objOutlookNameS pace.Logon

'Create the message
Set objOutlookMsg = objOutlook.Crea teItem(olMailIt em)

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*********@t imesnews.com")
Set objOutlookRecip = .Recipients.Add ("mi********@ti mesnews.com")
Set objOutlookRecip =
.Recipients.Add ("fr*********** *@timesnews.com ")
Set objOutlookRecip = .Recipients.Add ("br********@ti mesnews.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 = olImportanceHig h

'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
1210
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 default one for the user. I could not find a way to change the "from" address when sending a mail. Another way that would work would be to change to a different email account or change the default account to something different. I could find a way...
1
1717
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 profile. so when user clicks on a button my code has to show the appointments for that particular profile that was given there. i wrote a small procedure for that here's the code: ----------------------------
9
6725
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
1
1718
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 = OutApp.CreateItem(olMailItem) Then later in the code, I use 'With OutMail' to send emails.
6
21304
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 write: Dim oApp As New Outlook.Application
5
10591
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 logging on to other accounts on the network. Anybody know how to logon to other people's accounts using this method? //Create Outlook application Outlook.Application oApp = new Outlook.Application(); //Get MAPI namespace
1
1755
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 the following code... It works fine if there s only a one profile.. If there s more than one profile it will extract details from the folders under default profile... So my problem is How can I switch between the profiles.. ie, if there are two...
1
4383
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; CComPtr<_NameSpace> session; hr = application->GetNamespace(CComBSTR("MAPI"),&session.p); if(hr != S_OK) return hr; hr = application->get_Session(&session.p); if(hr != S_OK) return hr; hr =...
1
2091
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 'System.NullReferenceException' occurred in ConsoleApplication1.exe,Additional information: Object reference not set to an instance of an object .. Can anybody help me pls.... my code is like this..
0
8049
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7985
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8469
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8322
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5997
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3953
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4013
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2461
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.