我尝试使用方法构建一个dll发送电子邮件,在另一个编程平台中使用(开放边缘 - 进度),但它不起作用,因为它显示错误0x80040154(类未注册)。为了构建我的dll项目,我使用了this tutorial:
贝娄,我班上的全部代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.IO;
using System.Runtime.InteropServices;
namespace EnviaEmail
{
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("61495415-e035-4bc5-bc00-70e46c9766b8")]
public interface IMailFunctions
{
void EnviaMail(string fromMail, string toMail, string bodyMail, string subjectMail, string attachmentsMail, string smtpMail);
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None), Guid("0262794c-1858-40d8-90ca-cfe765913d3c")]
public class clsEnviaEmail : IMailFunctions
{
public clsEnviaEmail(){}
[ComVisible(true)]
public void EnviaMail(string fromMail, string toMail, string bodyMail, string subjectMail, string attachmentsMail, string smtpMail)
{
string[] attachmentsSplit = attachmentsMail.Split(new Char[] { ',' });
// Create the mail message
MailMessage mail = new MailMessage();
// Set the addresses
mail.From = new MailAddress(fromMail);
mail.CC.Add(toMail);
// Set the content
mail.Subject = subjectMail;
mail.IsBodyHtml = true;
mail.To.Add(toMail);
foreach (string s in attachmentsSplit)
{
if (s.Trim() != "")
mail.Attachments.Add(new Attachment(s));
}
using (StreamReader reader = File.OpenText(bodyMail))
{
mail.Body = reader.ReadToEnd();
}
// Send the message
SmtpClient smtp = new SmtpClient(smtpMail);
smtp.Send(mail);
}
}
}
有什么想法吗?