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

Opening an Outlook profile with VB

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.