我使用下面的代码将约会添加到收件人日历。 它适用于印度用户。但是当来自其他时区的用户添加约会时,它不会转换为当地时间。
任何人都可以帮忙吗?
Sub Click(Source As Button)
Dim session As New notessession
Dim workspace As New notesuiworkspace
Dim uidoc As NotesUIDocument
Dim mailDoc As notesdocument
Dim mailDB As NotesDatabase
Dim strDate As String
Dim strLocation As String
Dim strStartTime As String
Dim strEndTime As String
Dim userName As New NotesName(session.UserName)
Set uidoc=workspace.CurrentDocument
Set doc=uidoc.document
'**********Please modify this section before sending********
strTitle="Test"
strDate="11SEPTEMBER2014"
strLocation="BLR"
strStartTime="10:05"
strEndTime="10:20"
'************************************************************************
Set mailDB=session.CurrentDatabase
Set mailDoc=mailDB.CreateDocument
Set startTime=New NotesDateTime(strDate & " - " & strStartTime & " IST")
Set endTime=New NotesDateTime(strDate & " - " & strEndTime & " IST")
mailDoc.StartTimeZone="Z=-3005$DO=0$ZX=35$ZN=India"
mailDoc.EndTimeZone="Z=-3005$DO=0$ZX=35$ZN=India"
mailDoc.Form="Appointment"
mailDoc.AppointmentType="0"
mailDoc.Location=strLocation
mailDoc.Subject=strTitle
mailDoc.Principal=userName.Common
Dim currItem As NotesItem
Set currItem=mailDoc.AppendItemValue("StartDate", startTime)
Set currItem=mailDoc.AppendItemValue("StartDate", startTime)
Set currItem=mailDoc.AppendItemValue("EndDate", endTime)
Set currItem=mailDoc.AppendItemValue("StartTime", startTime)
Set currItem=mailDoc.AppendItemValue("EndTime", endTime)
Set currItem=mailDoc.AppendItemValue("StartDateTime", startTime)
Set currItem=mailDoc.AppendItemValue("EndDateTime", endTime)
Set currItem=mailDoc.AppendItemValue("CalendarDateTime", startTime)
'*********Popup for the Alarm***************
Call mailDoc.ReplaceItemValue("Alarms","1")
Call mailDoc.replaceitemvalue("$Alarm",1)
Call mailDoc.replaceitemvalue("$AlarmOffset",-120)
Call mailDoc.ReplaceItemValue("$AlarmUnit", "M")
Call mailDoc.ReplaceItemValue("$IconSwitcher", |Reminder|)
Call mailDoc.ReplaceItemValue("$AlarmMemoOptions", "")
Call mailDoc.ReplaceItemValue("dispAlarms","1")
Call mailDoc.ReplaceItemValue("dispAlarmsRd","1")
Call mailDoc.ReplaceItemValue("HideFromCalendar", "1")
'******************************End popup********
Call mailDoc.ReplaceItemValue("_ViewIcon",158)
Set currItem=doc.GetFirstItem("Body")
Call currItem.CopyItemToDocument(mailDoc,"Body")
Call mailDoc.ReplaceItemValue("SequenceNum","1")
Call mailDoc.ReplaceItemValue("$CSVersion",|2|)
Call mailDoc.ComputeWithForm(True, True)
Call mailDoc.Save(True, False)
On Error Resume Next
Set uidoc= workspace.EditDocument(True,mailDoc)
Set csEventObj= New CSCalendarEntry( 1, mailDoc, uidoc )
Call csEventObj.SetUIFlag( UI_FLAG_ALARM )
Call csEventObj.QueryClose( Continue)
Call csEventObj.QuerySave( True)
Call csEventObj.PostSave()
On Error Goto 0
''Call uidoc.Close(True)
''Dim var
''var=Messagebox("Calendar Entry added.", 0, "Mail Db")
End Sub
答案 0 :(得分:2)
如果查看手动创建的会议,您将看到StartDateTime包含日期和时间,但StartDate仅包含日期,StartTime仅包含时间。这不是你在这里做的,我怀疑那是你的问题。 另外,使用ReplaceItemValue而不是AppendItemValue来设置字段。而且我看到你不止一次设置相同的字段(因为你使用了错误的方法,使它成为多值的)。