这是我正在尝试使用的代码。但它实际上并没有按照我的意愿迭代数组来填充正文。我想要做的是使用C#创建一个Outlook电子邮件,并填充接收者,邮件主题,然后根据数组中包含的内容生成电子邮件的正文。编辑 - 我移动了每个循环,试图用数组中的每个元素填充正文,但是我得到了一个编译错误,无法使用此代码将int转换为字符串。Outlook主体的迭代阵列
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("[email protected]");
oRecip.Resolve();
oMsg.Save();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
}
}
catch
{
}
return null;
}
}
返回循环中的第一个语句,空catch ???你想做什么 ? – Habib
很多时候,一个好的旧步调试会话会节省您很多的时间和精力... –
标题编辑,你有C#标记,它不需要在标题中。 –