整合两个Outlook电子邮件 [英] Integrate two outlook emails

查看:83
本文介绍了整合两个Outlook电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处此代码向outlook发送两封电子邮件。一个使用newMessage,另一个使用MailManager。您可以帮忙将其作为一封电子邮件发送,并通过一封电子邮件发送内容。



ExchangeService服务=新的ExchangeService(ExchangeVersion.Exchange2007_SP1);

var assembly = Assembly.GetExecutingAssembly();

byte [] bytes = xyz.Properties.Resources.Template;





TinyUser tu = new TinyUser(r7929);

EmailMessage newMessage = new EmailMessage(service);







newMessage.SetExtendedProperty(binaryProperties,bytes);







tu.EMail = newMessage.ToRecipients.Add(niad@outlook.com)。ToString();



Absence ab = ServiceLookup.APServerProxy.GetAbsence(842);

Absences abs = new Absences();

abs.Add(ab);



UserAbsences ua = new UserAbsences(tu,abs);

UsersAbsences usa = new UsersAbsences();

USA.Add(ua);



Console.WriteLine(缺席(842);

AccreditorUsersAbsences aua = new AccreditorUsersAbsences(tu ,美国);



TinyUser tua =新的TinyUser(r7929);

tua.EMail = newMessage.ToRecipients.Add( niad@outlook.com)。ToString();

aua.Accreditor = tua;



MailManager.Instance.SendMailToAccreditor(aua) ;



newMessage.Subject =请假;

newMessage.Body = new MessageBody(Email Body);

newMessage.Send();

Here this code is sending two emails to outlook. one with newMessage and other with MailManager. Could you please help to make it as one email and send both the contents on one email.

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
var assembly = Assembly.GetExecutingAssembly();
byte[] bytes = xyz.Properties.Resources.Template;


TinyUser tu = new TinyUser("r7929");
EmailMessage newMessage = new EmailMessage(service);



newMessage.SetExtendedProperty(binaryProperties, bytes);



tu.EMail = newMessage.ToRecipients.Add("niad@outlook.com").ToString();

Absence ab = ServiceLookup.APServerProxy.GetAbsence(842);
Absences abs = new Absences();
abs.Add(ab);

UserAbsences ua = new UserAbsences(tu, abs);
UsersAbsences usa = new UsersAbsences();
usa.Add(ua);

Console.WriteLine("Absence of (842");
AccreditorUsersAbsences aua = new AccreditorUsersAbsences(tu, usa);

TinyUser tua = new TinyUser("r7929");
tua.EMail = newMessage.ToRecipients.Add("niad@outlook.com").ToString();
aua.Accreditor = tua;

MailManager.Instance.SendMailToAccreditor(aua);

newMessage.Subject = "Request for vacation";
newMessage.Body = new MessageBody("Email Body");
newMessage.Send();

推荐答案

只需删除此行:

Just remove this line:
MailManager.Instance.SendMailToAccreditor(aua);





您已将两个收件人添加到newMessage。我并不完全理解你在对你的课程做了什么,但是这会减少代码只能通过Microsoft exchange发送一条消息。我猜测MailManager是您构建的内部类,SendMailToAccreditor方法在使用AccreditorUsersAbsences类型的参数调用时会创建消息完全填充的电子邮件。



我不知道你想要什么,但如果你只想要一封电子邮件出去,如果你想要从MailManager发送的电子邮件去,请删除上面一行out(明智的电子邮件)然后你需要修改该类并删除newMessage。



我希望有所帮助。在不确切知道你想要什么的情况下将它们合并到一封电子邮件中并不是一个好的答案,因为你正在发送2条消息,其中一条正在这段代码中生成,一条正在MailManager中生成,所以在我再给予帮助之前需要更多的信息。 br $>


Damien



You have already added both recipients to newMessage. I don't totally understand what you are doing with your classes, but this will reduce the code to only send one message via Microsoft exchange. I am guessing that MailManager is a internal class that you built and the SendMailToAccreditor method creates a message fully populated email when called with a parameter of type AccreditorUsersAbsences.

I have no idea what you are wanting but if you just want one email to go out remove the line above if you want the email that is sent from MailManager to go out (email body wise) then you will need to modify that class and remove the newMessage.

I hope that helps. Without knowing exactly what you want and Combining them into one email is not a good answer because you are sending 2 messages one is being generated in this code and one is being generated in MailManager so more info is needed before I can give anymore help.

Damien


这篇关于整合两个Outlook电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆