Menu

Newbie problem

2006-02-25
2013-04-02
  • Graham Robinson

    Graham Robinson - 2006-02-25

    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("&lt;html&gt;&lt;body&gt;" & _
                    "&lt;p&gt;Just checking up on where you were last night.&lt;/p&gt;\r\n" & _
                    "&lt;p&gt;Send me a note!&lt;/p&gt;\r\n\r\n" & _
                    "&lt;p&gt;-Charles&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;")
                   
                emailMessage.Send(new SmtpServer("localhost"))
    End Sub

    </script>

    I would appreciate any pointer you can give.
    Thanks
    Graham

     
    • Mike Bridge

      Mike Bridge - 2006-02-26

      Hi-

      Yes, I think the error is in the Import statement, not the EmailMessage object declaration.  It should be:

         <% @Import Namespace="DotNetOpenMail" %>

      Cheers,

      -Mike

       
    • Graham Robinson

      Graham Robinson - 2006-02-26

      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

       
      • Mike Bridge

        Mike Bridge - 2006-02-27

        Hi-

        Normally, it should go in the /bin directory.

        Cheers,

        -Mike

         
    • Graham Robinson

      Graham Robinson - 2006-02-27

      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

       
      • Mike Bridge

        Mike Bridge - 2006-02-27

        Hi-

        Glad to hear it works!

        Cheers,

        -Mike

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.