Opening an Outlook profile with VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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("(e-mail address removed)")
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
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
 
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,
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top