这是我正在尝试使用的代码。但它实际上并没有按照我的意愿迭代数组来填充身体。我想要做的是使用 C# 创建一个 Outlook 电子邮件,并填充接收者、消息主题,然后根据数组中包含的内容生成电子邮件的正文。编辑 - 我移动了 for each 循环以尝试用数组的每个元素填充主体,但我得到一个编译错误,无法使用此代码将 int 转换为字符串。
public static string GenerateEmail()
{
try
{
for (int q = eName.GetLowerBound(0); q <= eName.GetUpperBound(0); q++)
{
return Global.Variables.GlobalVariables.eName[q];
Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
for (int q = eName.GetLowerBound(0); q <= eName.GetUpperBound(0); q++)
{
oMsg.HTMLBody = q;
}
oMsg.Subject = "Reports Are Ready";
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("123123123@testemail.com");
oRecip.Resolve();
oMsg.Save();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
}
}
catch
{
}
return null;
}
}