Public Folder Items

  • Thread starter James Bond via OfficeKB.com
  • Start date
J

James Bond via OfficeKB.com

Hello,

I have for a times ago a treed with the same problem. But the problem is not
solved. Sorry.

Public Function MakeAppointment(strOutlookFolderID As String, strSubject As
String, datDatum As Date, strLocation As String, strBody As String, bolAllDay
As Boolean, Optional strvon As String, Optional strbis As String, Optional
strOutlook As String, Optional strOutlookStorID) As String
5 On Error GoTo Handler
Dim olfolder As Outlook.MAPIFolder
Dim olApp As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim olns As Outlook.Namespace

10 Set olApp = CreateObject("Outlook.Application")
15 Set olns = olApp.GetNamespace("MAPI")
20 olns.Logon , , False, False

25 If Nz(strOutlookStorID) = "" Then
30 Set olfolder = olns.GetFolderFromID(strOutlookFolderID)
35 Else
40 Set olfolder = olns.GetFolderFromID(strOutlookFolderID,
strOutlookStorID)
45 End If

50 If Nz(strOutlook) = "" Then
55 Set objAppt = olfolder.Items.Add
60 Else
65 Set objAppt = olns.GetItemFromID(strOutlook, olfolder.StoreID)
70 End If


75 With objAppt
80 .Subject = strSubject
85 If Nz(Trim(strLocation)) <> "" Then
90 .Location = strLocation
95 End If
100 If bolAllDay = False Then
105 .Start = CDate(datDatum & " " & strvon & ":00")
110 .End = CDate(datDatum & " " & strbis & ":00")
115 .AllDayEvent = False
120 Else
125 .Start = datDatum
130 .AllDayEvent = True
135 End If

'recurring appointment
'.IsRecurring

140 .ReminderSet = False
145 .Body = strBody
'.Importance = olImportanceHigh
150 .Save
155 MakeAppointment = .EntryID
160 End With

165 olns.Logoff

170 Set objAppt = Nothing
175 Set olfolder = Nothing
180 Set olns = Nothing
185 Set olApp = Nothing
190 Exit Function
Handler:
195 MsgBox Err.Number & "|" & Err.Description & "|" & Erl()
End Function


Now I get an Error in line 40.
Mainly when Outlook was closed.

Waht can I do. How can I start Outlook per VBA?

Thanks for all ideas.

James
 
S

Sue Mosher [MVP-Outlook]

You probably need to include parameters in your Namespace.Logon statement to tell Outlook what mail profile to load. Line 20 now assumes that Outlook is open or that a default mail profile will load automatically.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/com...spx?dg=microsoft.public.outlook.program_vba65

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

James Bond via OfficeKB.com

Hello Sue,

that's all?

Thanks
James
You probably need to include parameters in your Namespace.Logon statement to tell Outlook what mail profile to load. Line 20 now assumes that Outlook is open or that a default mail profile will load automatically.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/com...spx?dg=microsoft.public.outlook.program_vba65
[quoted text clipped - 71 lines]
 
J

James Bond via OfficeKB.com

Hello Sue,

Is an emty string OK?

olns.Logon "" ,"" , False, False

Or how can I get the Stantard Profil via VBA?

James

James said:
Hello Sue,

that's all?

Thanks
James
You probably need to include parameters in your Namespace.Logon statement to tell Outlook what mail profile to load. Line 20 now assumes that Outlook is open or that a default mail profile will load automatically.
[quoted text clipped - 5 lines]
 
S

Sue Mosher [MVP-Outlook]

That's the problem that I'm trying to draw your attention to. If you just use an empty string and Outlook isn't running, it may not know what mail profile to use to start Outlook. Ideally, your application should either be a COM add-in, so that it uses whatever profile Outlook is already launched with, or it should ask the user what profile it should use.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

James Bond via OfficeKB.com

Hello Sue,

I want to start the standard profile.
How can I start Outlook. Can I search the outlook.exe and start it with
shell?

MFG
Marius
That's the problem that I'm trying to draw your attention to. If you just use an empty string and Outlook isn't running, it may not know what mail profile to use to start Outlook. Ideally, your application should either be a COM add-in, so that it uses whatever profile Outlook is already launched with, or it should ask the user what profile it should use.
Hello Sue,
[quoted text clipped - 14 lines]
 
S

Sue Mosher [MVP-Outlook]

Calling CreateObject("Outlook.Application") will start Outlook (assuming your anti-virus software doesn't block it).

By "standard profile," do you mean the user's default profile?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


James Bond via OfficeKB.com said:
Hello Sue,

I want to start the standard profile.
How can I start Outlook. Can I search the outlook.exe and start it with
shell?

MFG
Marius
That's the problem that I'm trying to draw your attention to. If you just use an empty string and Outlook isn't running, it may not know what mail profile to use to start Outlook. Ideally, your application should either be a COM add-in, so that it uses whatever profile Outlook is already launched with, or it should ask the user what profile it should use.
Hello Sue,
[quoted text clipped - 14 lines]
You probably need to include parameters in your Namespace.Logon statement to tell Outlook what mail profile to load. Line 20 now assumes that Outlook is open or that a default mail profile will load automatically.
 
J

James Bond via OfficeKB.com

Hello Sue,

Yes, I mean the user's default profile.

Mfg
Marius
Calling CreateObject("Outlook.Application") will start Outlook (assuming your anti-virus software doesn't block it).

By "standard profile," do you mean the user's default profile?
Hello Sue,
[quoted text clipped - 12 lines]
 

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

Top