Wilder1626
asked on
VB6 - Issue to send the calandar event to required attendees Microsoft Outlook
Hi
I'm having a problem with the below code.
This code will create a Microsoft Outlook event and all add required attendees.
The issue I'm getting is that it does not send to attendees at all, unless i open the calendar event after and then, click send.
I really want to send it right away without having to re open the even.
How can i do that?
Thanks
I'm having a problem with the below code.
This code will create a Microsoft Outlook event and all add required attendees.
The issue I'm getting is that it does not send to attendees at all, unless i open the calendar event after and then, click send.
I really want to send it right away without having to re open the even.
How can i do that?
Thanks
Dim objApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objFolder As Outlook.MAPIFolder
Dim objDummy As Outlook.MailItem
Dim objRecip As Outlook.Recipient
Dim objAppt As Outlook.AppointmentItem
Dim strMsg As String
Dim strName As String
On Error Resume Next
' ### name of person whose Calendar you want to use ###
strName = "email.address"
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objDummy = objApp.CreateItem(olMailItem)
Set objRecip = objDummy.Recipients.Add(strName)
objRecip.Resolve
If objRecip.Resolved Then
On Error Resume Next
Set objFolder = _
objNS.GetSharedDefaultFolder(objRecip, _
olFolderCalendar)
If Not objFolder Is Nothing Then
Set objAppt = objFolder.Items.Add
If Not objAppt Is Nothing Then
With objAppt
.RequiredAttendees = "email.address;email.address"
.Subject = "Store flip "
.Start = year1 & "/" & month1 & "/" & day1
.AllDayEvent = True
.Body = "Please create in new store location"
.BusyStatus = olBusy
.Send
.Save
End With
End If
End If
Else
MsgBox "Could not find " & Chr(34) & strName & Chr(34), , _
"User not found"
End If
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objDummy = Nothing
Set objRecip = Nothing
Set objAppt = Nothing
ASKER
On row 35, i do have .Send
do i need to set that 2 times?
do i need to set that 2 times?
ahh no, first remove your on error resume next, to see what is happening. You may be getting an error and may not know it.
ASKER
I have removed the ON ERROR RESUME NEXT. I don't have any errors.
i may add that the attendees are network users only and i'm on Lync also. I dont know if this can change something in the config.
i may add that the attendees are network users only and i'm on Lync also. I dont know if this can change something in the config.
You had 2 on error resume next, did you remove both?
ASKER
Yes, both are removed and no error happen
I have a feeling that the application is exiting too soon and does not have a chance to be sent. Move your objects outside your function (declare globally) and place a timer on the form that waits xx seconds before setting the objects to null
ASKER
if i put a sleep time in between, should this work normally?
I dont see any change in the result.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
I dont see any change in the result.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Else
MsgBox "Could not find " & Chr(34) & strName & Chr(34), , _
"User not found"
End If
'Timer1
Sleep 50000
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objDummy = Nothing
Set objRecip = Nothing
Set objAppt = Nothing
End If
sleep isn't going to relinquish control back to the program. That's why you set a timer after the function then n the timer trigger close the items.
ASKER
i just tried that but still the same result.
How would you set the timer?
Just like this?
How would you set the timer?
Just like this?
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objDummy = Nothing
Set objRecip = Nothing
Set objAppt = Nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Randy
even if i put the entire sub routine in the timer, i still have the same result.
even if i put the entire sub routine in the timer, i still have the same result.
ASKER
After some other tests, still not a good result.
is it possible to run the script but when it will be the time to send, it will let me do it manually bu clicking on the send button?
is it possible to run the script but when it will be the time to send, it will let me do it manually bu clicking on the send button?
.RequiredAttendees = "email.address;email.address"
.Subject = "Store flip "
.Start = year1 & "/" & month1 & "/" & day1
.AllDayEvent = True
.Body = "Please create in new store location"
.BusyStatus = olBusy
ASKER
i found it. i need to use .Display.
I will do some test
I will do some test
ASKER
i still have the same issue
but i think i know why, but cannot see how to fix this.
when the calendar app display, if i click inside the RequiredAttendees field, it validate the name. then, it send the appointment. But if i dont select the attendees field, it does not work. Probably because it does not recognize the email address.
would you know why?
but i think i know why, but cannot see how to fix this.
when the calendar app display, if i click inside the RequiredAttendees field, it validate the name. then, it send the appointment. But if i dont select the attendees field, it does not work. Probably because it does not recognize the email address.
would you know why?
ASKER
Hi Randy
this is working now. Thanks a lot for your help.
this is working now. Thanks a lot for your help.
objDummy .Send