Dim emailMessage As EmailMessage
emailMessage = new EmailMessage()
emailMessage.FromAddress = new EmailAddress("cswann@XXXXXX.com", "Charles Swann")
emailMessage.AddToAddress(new EmailAddress("ocrecy@XXXXXX.com", "Odette de Crecy"))
emailMessage.Subject = "Missed you"
emailMessage.TextPart = new TextAttachment("Just checkie you were last night.\r\nSend me a note!")
emailMessage.HtmlPart = new HtmlAttachment("<html><body>" & _
"<p>Just checking up on where you were last night.</p>\r\n" & _
"<p>Send me a note!</p>\r\n\r\n" & _
"<p>-Charles</p></body></html>")
emailMessage.Send(new SmtpServer("localhost"))
End Sub
</script>
I would appreciate any pointer you can give.
Thanks
Graham
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying to use the dll from ASP.net using VB.net 1.1
I keep getting the error back 'EmailMessage' is not defined.
Can you tell me where to put the dll, and how to reference it from vb.net
Here is the source code.
------------- GrahamTextMail.aspx --------
<% @Import Namespace="DotNetOpenMail.EmailMessage" %>
<!-- #Include file="GrahamTextMail.vb" -->
<body class="ItemCSS">
<form runat="server" ID="Form1">
<% SendMail() %>
done...
</form>
</body>
----------- GrahamTextMail.VB -------------
<script runat="server" language="VB">
Sub SendMail()
Dim emailMessage As EmailMessage
emailMessage = new EmailMessage()
emailMessage.FromAddress = new EmailAddress("cswann@XXXXXX.com", "Charles Swann")
emailMessage.AddToAddress(new EmailAddress("ocrecy@XXXXXX.com", "Odette de Crecy"))
emailMessage.Subject = "Missed you"
emailMessage.TextPart = new TextAttachment("Just checkie you were last night.\r\nSend me a note!")
emailMessage.HtmlPart = new HtmlAttachment("<html><body>" & _
"<p>Just checking up on where you were last night.</p>\r\n" & _
"<p>Send me a note!</p>\r\n\r\n" & _
"<p>-Charles</p></body></html>")
emailMessage.Send(new SmtpServer("localhost"))
End Sub
</script>
I would appreciate any pointer you can give.
Thanks
Graham
Hi-
Yes, I think the error is in the Import statement, not the EmailMessage object declaration. It should be:
<% @Import Namespace="DotNetOpenMail" %>
Cheers,
-Mike
Hi Mike,
Thanks for the advice, I've tried that and it hasn't
helped.
At the moment I have the DLL in the root of the default web site - is this the correct place ?.
Cheers
Graham
Hi-
Normally, it should go in the /bin directory.
Cheers,
-Mike
Hi Mike,
I have created a /bin and put in the dll, and
bobs your uncle everything works great ;-)
Thanks for all your help
Graham
Hi-
Glad to hear it works!
Cheers,
-Mike