 |
|
ASP.NET C# ส่งอีเมล์เข้า Lotus Notes ตอน Debug ใช้งานได้ปกติ แต่เรียกจากเว็บ มี error |
|
 |
|
|
 |
 |
|
Code
Server Error in '/mail2domino' Application.
Retrieving the COM class factory for component with CLSID {29131539-2EED-1069-BF5D-00DD011186B7} failed due to the following error: 8007000e.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Retrieving the COM class factory for component with CLSID {29131539-2EED-1069-BF5D-00DD011186B7} failed due to the following error: 8007000e.
งงมากครับ
ตอนแรกทดลองเรียกจากเว็บ ใช้งานได้แล้ว แต่พอ restart เครื่อง เพื่อจะเขียนรายละเอียดอื่นๆ เติมลงไป ลองเรียกแล้วเจอ error นี้เลย แต่แปลกว่า ทดลอง debug กลับ run ผ่านปกติ
code ครับ
Code
<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="Domino" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
lblMessage.Text = "click button to send mail";
}
protected void Button1_Click(object sender, EventArgs e)
{
//Create new notes session
NotesSession _notesSession = new NotesSession(); // <------ error ที่บรรทัดนี้ครับ มึนมาก
NotesDatabase _notesDataBase = null;
NotesDocument _notesDocument = null;
object oItemValue = null;
//Initialize Notes Session
_notesSession.Initialize("lotusnotespassword");
//Get Database via server name & c:\notes\data\mailfilename.nsf
//if not found set to false to not create one
_notesDataBase = _notesSession.GetDatabase("dominoserver/Domain", "mail\\username.nsf", false);
//If the database is not already open then open it.
bool dbopen = _notesDataBase.IsOpen;
if (!dbopen)
{
_notesDataBase.Open();
}
//Create the notes document
_notesDocument = _notesDataBase.CreateDocument();
//Set document type
_notesDocument.ReplaceItemValue("Form", "Memo");
//sent notes memo fields (To: CC: Bcc: Subject etc)
_notesDocument.ReplaceItemValue("SendTo", "[email protected]");
_notesDocument.ReplaceItemValue("CopyTo", "[email protected]");
_notesDocument.ReplaceItemValue("Subject", "Test Mail");
//Set the body of the email. This allows you to use the appendtext
NotesRichTextItem _richTextItem = _notesDocument.CreateRichTextItem("Body");
//add lines to memo email body. the \r\n is needed for each new line.
_richTextItem.AppendText("Hello: " + "User" + "\r\n");
//send email & pass in byRef field, this case SendTo (always have this,
//cc or bcc may not always be there.
oItemValue = _notesDocument.GetItemValue("SendTo");
_notesDocument.Send(false, ref oItemValue);
//release resources.
_richTextItem = null;
_notesDocument = null;
_notesDataBase = null;
_notesSession = null;
lblMessage.Text = "mail sent";
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Send Test" Width="120px"
onclick="Button1_Click" />
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
มีท่านใดพอจะทราบสาเหตุบ้างหรือไม่ครับ ขอบคุณมากครับ
Tag : .NET, C#
|
|
 |
 |
 |
 |
Date :
2012-10-26 12:14:33 |
By :
Aod47 |
View :
1619 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ต้องเข้าใจก่อนนะครับว่าบน Web Server ที่เราเอาไฟล์ไปวางนั้นอาจจะไม่ได้ลงโปรแกรม Lotus Note ไว้
พอเราไป Run บน Server มันจึงมีปัญหาดังกล่าวครับ หรือ ถ้าลง Lotus Note ไว้แล้วตัว DLL อาจจะไม่
รองรับการทำงานบน Web ก็ได้นะครับ
วิธีการแก้ปัญหาก็คือ คุณต้องไปใช้การส่งเมล์โดย SMTP ครับ คือทำการเรียกใช้ Class ของ .NET เองแล้ว
ก็ connect ตัวเมล์ Server ผ่านทาง IP ครับ เท่านั้นคุณก็จะทำการส่งเมล์ได้แล้วครับ ลองดูตัวอย่างด้านล่างครับ
Code (VB.NET)
Dim mailMsg As New MailMessage
Dim MailClient As New SmtpClient("MailServer", "MailPort")
mailMsg.Priority = MailPriority.Normal
mailMsg.From = New MailAddress("MailSender", "MailSender" & " <Do not reply>")
mailMsg.To.Add("Receiver")
mailMsg.Subject = "Your subject"
mailMsg.IsBodyHtml = True
mailMsg.Body = ""
MailClient.Send(mailMsg)
|
ประวัติการแก้ไข 2012-10-26 14:19:53
 |
 |
 |
 |
Date :
2012-10-26 14:18:47 |
By :
smeproject |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้า Debug ผ่าน แต่รันผ่าน IIS ไม่ผ่าน คิดว่าน่าจะมีปัญหาที่ Permission อะไรวะอย่างครับ
|
 |
 |
 |
 |
Date :
2012-10-26 14:31:45 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|