仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1061|回复: 9
打印 上一主题 下一主题

[学习教程] ASP.NET网站制作之怎样在 C# 中倡议集会之类的特别邮件

[复制链接]
金色的骷髅 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:24:06 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
竟发现没有太大的帮助。总觉得要用起来,感觉到不了位。因为公司机器的原因,一直没有安装vs.net(也从来没有用过)。以前做asp的时候一直用DW(感觉其代码联想功能不错),可现在到了asp.net却不习惯了。从C#中挪用Outlook中的API,能够倡议集会之类的特别邮件。办法以下:创立项目后,为它增加.NET援用:“Microsoft.Office.Interop.Outlook“的援用,便可挪用,必要注重的是,在增加的时分,注重一下Office版本号。在挪用其API倡议集会的过程当中,碰到了一个成绩:
创立完一个约会条目后,找了好久没找到怎样为这一约会指定“发件人”,厥后一想,WindowCF中,查找职员信息有个OutlookSession的东东,
那这Outlook会不会有一样的体例呢,经由测试,还真的找到办法,本来,它的API指定的发件人是和你机上运转的Outlook的帐户设置间接相干的。
经由过程ApplicationClass.Session.Accounts便可找到您设置的帐户汇合,必要出格出格注重的是,在这里,取某团体员时,汇合的索引是从1入手下手,而不是
从0入手下手。找到相干的帐户后,能够经由过程AppointmentItem.SendUsingAccount属性来指定约会的发件人。
上面是测试的代码,在WIN2003+OFFICE12下运转经由过程,乐成创立集会:
以下为援用的内容:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingMicrosoft.Office.Interop.Outlook;
/**/////////////////////
/**//*挪用Outlookapi倡议集会
/*mcjeremy@cnblogs.com
////////////////////
namespaceOutlookAPI
{
classProgram
{
staticvoidMain(string[]args)
{
try
{
ApplicationClassoApp=newMicrosoft.Office.Interop.Outlook.ApplicationClass();
//集会是约会的一种
AppointmentItemoItem=(AppointmentItem)oApp.CreateItem(OlItemType.olAppointmentItem);
oItem.MeetingStatus=OlMeetingStatus.olMeeting;
oItem.Subject="主题";
oItem.Body="内容";
oItem.Location="地址";
//入手下手工夫 
oItem.Start=DateTime.Now.AddDays(1);
//停止工夫
oItem.End=DateTime.Now.AddDays(2);
//提示设置
oItem.ReminderSet=true;
oItem.ReminderMinutesBeforeStart=5;
//是不是全天事务
oItem.AllDayEvent=false;
oItem.BusyStatus=OlBusyStatus.olBusy;
//索引从1入手下手,而不是从0
//发件人的帐号信息
oItem.SendUsingAccount=oApp.Session.Accounts[2];
//增加必选人
Recipientforce=oItem.Recipients.Add("mailuser2@mailserver.com");
force.Type=(int)OlMeetingRecipientType.olRequired;
//增加可选人
Recipientopt=oItem.Recipients.Add("mailuser3@p.mailserver.com");
opt.Type=(int)OlMeetingRecipientType.olOptional;
//增加集会倡议者
Recipientsender=oItem.Recipients.Add("mailuser1@mailserver.com");
sender.Type=(int)OlMeetingRecipientType.olOrganizer;
oItem.Recipients.ResolveAll();
//oItem.SaveAs("d:/TEST.MSG",OlSaveAsType.olMSG);
oItem.Send();
//MailItemmItem=(MailItem)oApp.CreateItem(OlItemType.olMailItem);
//RecipientrTo=mItem.Recipients.Add("****");
//rTo.Type=(int)OlMailRecipientType.olTo;
//RecipientrCC=mItem.Recipients.Add("****");
//rCC.Type=(int)OlMailRecipientType.olCC;
//RecipientrBC=mItem.Recipients.Add("****");
//rBC.Type=(int)OlMailRecipientType.olBCC;
Console.WriteLine("OK");
}
catch(System.Exceptionex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}

java的设计机制:首先产生一个中间码,第二部编译为本地(机器)码。这个机制有很大的缺点。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-19 23:26

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表