S
srinivas
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:
----------------------------
Private Sub btnProfile1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnProfile1.Click
olProfile("Sample1")
End Sub
Private Sub btnProfile2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnProfile2.Click
olProfile("Sample2")
End Sub
Private Sub btnProfile3_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnProfile3.Click
olProfile("Sample3")
End Sub
//This is the procedure....
Private Sub olProfile(ByVal profile As String)
MsgBox("Generating for the profile:" & profile)
Dim appProfile As Outlook.Application = New
Outlook.Application()
Dim nsProfile As Outlook.NameSpace =
appProfile.GetNamespace("mapi")
nsProfile.Logon(profile, , False, True)
Dim fldrProfile As Outlook.MAPIFolder =
nsProfile.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim aProfile As Outlook.Items = fldrProfile.Items
Dim aptProfile As Outlook.AppointmentItem
Dim iProfile As Integer
MsgBox("Appointment Information from the profile" & profile)
MsgBox(aProfile.Count)
aptProfile = aProfile.GetFirst
For iProfile = 0 To aProfile.Count - 1
MsgBox("Subject:" & aptProfile.Subject & vbCrLf & "
Location:" & aptProfile.Location & vbCrLf & "Start Time:" &
aptProfile.Start & vbCrLf & " End Time:" & aptProfile.End)
aptProfile = aProfile.GetNext
Next
nsProfile.Logoff()
appProfile = Nothing
nsProfile = Nothing
aProfile = Nothing
aptProfile = Nothing
End Sub
----------------------------------------
When i click on one of button it's showing the appointments for that
profile.If i click another button then also it's working fine.
HERE's the problem:
From then onwards if i click any button it's showing the previous
profile's appointments only,irrespective of the button.
here i was caught....how to get rid of this...?
Is there any way to check whether outlook application was launched or
not...if so with what profile??
Can anyone please help me....
Thanks in advance...
Srinivas
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:
----------------------------
Private Sub btnProfile1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnProfile1.Click
olProfile("Sample1")
End Sub
Private Sub btnProfile2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnProfile2.Click
olProfile("Sample2")
End Sub
Private Sub btnProfile3_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnProfile3.Click
olProfile("Sample3")
End Sub
//This is the procedure....
Private Sub olProfile(ByVal profile As String)
MsgBox("Generating for the profile:" & profile)
Dim appProfile As Outlook.Application = New
Outlook.Application()
Dim nsProfile As Outlook.NameSpace =
appProfile.GetNamespace("mapi")
nsProfile.Logon(profile, , False, True)
Dim fldrProfile As Outlook.MAPIFolder =
nsProfile.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim aProfile As Outlook.Items = fldrProfile.Items
Dim aptProfile As Outlook.AppointmentItem
Dim iProfile As Integer
MsgBox("Appointment Information from the profile" & profile)
MsgBox(aProfile.Count)
aptProfile = aProfile.GetFirst
For iProfile = 0 To aProfile.Count - 1
MsgBox("Subject:" & aptProfile.Subject & vbCrLf & "
Location:" & aptProfile.Location & vbCrLf & "Start Time:" &
aptProfile.Start & vbCrLf & " End Time:" & aptProfile.End)
aptProfile = aProfile.GetNext
Next
nsProfile.Logoff()
appProfile = Nothing
nsProfile = Nothing
aProfile = Nothing
aptProfile = Nothing
End Sub
----------------------------------------
When i click on one of button it's showing the appointments for that
profile.If i click another button then also it's working fine.
HERE's the problem:
From then onwards if i click any button it's showing the previous
profile's appointments only,irrespective of the button.
here i was caught....how to get rid of this...?
Is there any way to check whether outlook application was launched or
not...if so with what profile??
Can anyone please help me....
Thanks in advance...
Srinivas