从代码分配 Outlook 约会重复类型
Assigning Outlook Appointment recurrence type from code
我正在尝试通过代码在 Outlook 中添加约会。 "Outlook.AppointmentItem" 对象有一个名为 "GetRecurrencePattern().RecurrenceType" 的属性。当我尝试将此属性设置为 "OlRecurrenceType.olRecursDaily" 时,它会自动转换为 "OlRecurrenceType.olRecursWeekly".
这是我的代码:
Outlook.AppointmentItem oMeet;
Meeting Meet;
Hashtable htrecc = GetReccuranceTable(strRec);
if (Meet.recctype.Substring(0, 3) == "day")
{
oMeet.GetRecurrencePattern().RecurrenceType = OlRecurrenceType.olRecursDaily;
OlRecurrenceType pattern2 = oMeet.GetRecurrencePattern().RecurrenceType;
string rectype = pattern2.ToString();
oMeet.GetRecurrencePattern().Interval = Convert.ToInt32(htrecc["Interval"]);
if (string.Equals("no", htrecc["Occurence"]))
oMeet.GetRecurrencePattern().NoEndDate = true;
else
if (!string.IsNullOrEmpty(Convert.ToString(htrecc["Occurence"])))
oMeet.GetRecurrencePattern().Occurrences = Convert.ToInt32(htrecc["Occurence"]);
else
oMeet.GetRecurrencePattern().PatternEndDate = Meet.EndTime;
}
字符串"rectype" returns一个值“olRecursWeekly”
如果我在某处出错,请提出建议。
每次调用 GetRecurrencePattern() 时,您都会得到一个全新的 RecurrentPattern COM 对象。不要每次都调用 GetRecurrencePattern() - 调用一次,缓存值,并在代码中的任何地方使用它
Outlook.RecurrencePattern pattern = oMeet.GetRecurrencePattern();
pattern.RecurrenceType = OlRecurrenceType.olRecursDaily;
OlRecurrenceType pattern2 = pattern.RecurrenceType;
string rectype = pattern2.ToString();
pattern.Interval = Convert.ToInt32(htrecc["Interval"]);
if (string.Equals("no", htrecc["Occurence"]))
pattern.NoEndDate = true;
else
if (!string.IsNullOrEmpty(Convert.ToString(htrecc["Occurence"])))
pattern.Occurrences = Convert.ToInt32(htrecc["Occurence"]);
else
pattern.PatternEndDate = Meet.EndTime;
我正在尝试通过代码在 Outlook 中添加约会。 "Outlook.AppointmentItem" 对象有一个名为 "GetRecurrencePattern().RecurrenceType" 的属性。当我尝试将此属性设置为 "OlRecurrenceType.olRecursDaily" 时,它会自动转换为 "OlRecurrenceType.olRecursWeekly".
这是我的代码:
Outlook.AppointmentItem oMeet;
Meeting Meet;
Hashtable htrecc = GetReccuranceTable(strRec);
if (Meet.recctype.Substring(0, 3) == "day")
{
oMeet.GetRecurrencePattern().RecurrenceType = OlRecurrenceType.olRecursDaily;
OlRecurrenceType pattern2 = oMeet.GetRecurrencePattern().RecurrenceType;
string rectype = pattern2.ToString();
oMeet.GetRecurrencePattern().Interval = Convert.ToInt32(htrecc["Interval"]);
if (string.Equals("no", htrecc["Occurence"]))
oMeet.GetRecurrencePattern().NoEndDate = true;
else
if (!string.IsNullOrEmpty(Convert.ToString(htrecc["Occurence"])))
oMeet.GetRecurrencePattern().Occurrences = Convert.ToInt32(htrecc["Occurence"]);
else
oMeet.GetRecurrencePattern().PatternEndDate = Meet.EndTime;
}
字符串"rectype" returns一个值“olRecursWeekly” 如果我在某处出错,请提出建议。
每次调用 GetRecurrencePattern() 时,您都会得到一个全新的 RecurrentPattern COM 对象。不要每次都调用 GetRecurrencePattern() - 调用一次,缓存值,并在代码中的任何地方使用它
Outlook.RecurrencePattern pattern = oMeet.GetRecurrencePattern();
pattern.RecurrenceType = OlRecurrenceType.olRecursDaily;
OlRecurrenceType pattern2 = pattern.RecurrenceType;
string rectype = pattern2.ToString();
pattern.Interval = Convert.ToInt32(htrecc["Interval"]);
if (string.Equals("no", htrecc["Occurence"]))
pattern.NoEndDate = true;
else
if (!string.IsNullOrEmpty(Convert.ToString(htrecc["Occurence"])))
pattern.Occurrences = Convert.ToInt32(htrecc["Occurence"]);
else
pattern.PatternEndDate = Meet.EndTime;