As noted in a previous message on this thread, Outlook is generally not
considered a reliable solution on the server.  However, if you choose
this approach the following code will work:

Imports Outlook = Microsoft.Office.Interop.Outlook
.....

Dim olApp As Outlook.Application = New Outlook.Application()
Dim olNS As Outlook.NameSpace = olApp.GetNamespace("mapi")
olNS.Logon("", "", True, True)
Dim olItem As Outlook.MailItemClass = _
CType(olApp.CreateItem(Outlook.OlItemType.olMailItem), _
            Outlook.MailItemClass)
With olItem
    .Recipients.Add("[EMAIL PROTECTED]")
    .Recipients.ResolveAll()
    .Subject = "Testing"
    .Send()
End With

Note this will trigger the Outlook security dialog. For details and
development workarounds see:
http://www.slipstick.com/outlook/esecup.htm.  You can avoid the security
prompts by using the Redemption library which will work with .NET.  See
http://www.dimastr.com/redemption.

- Mike

Mike Timms
Robard Systems


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED]] On Behalf Of Barraud
Peter(KSA)
Sent: December 11, 2002 11:51 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Web Mail

Hi Everybody,
It's great to read some many responses. Ok here's the problem is detail
I am attaching to sets of code one is a simple code for web mail
(nothing
flashy)
The next is a code using the outlook com object, the reason why I chose
the
second is simply becos the first doesn't work
It gives this error message - "Could not create CDO.Message object"
Then I tried the second approach of using the outlook object and that
didn't
work either so finally I installed outlook on the server and now it
works
but with a horrid work around
I am not giving the work-around here since using outlook is a last ditch
effort so if someone can help with the webmail that would be
wonderful-wonderful
Please note that I've found some solution if someone's really desperate
but
it's a pathetic solution that's why I trying something better
thanks
peter

Web Mail Code
===========

    Private Sub cmdWebMail2_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles cmdWebMail2.Click
        Try
            Dim objmail As New MailMessage()
            Dim objCOnfig As SmtpMail
            Dim sSMTPServer As String = Trim(TextBox1.Text)
            If sSMTPServer = "" Then
                MsgBox("enter smtp server name")
                Exit Sub
            End If
            objmail.From = sFROM
            objmail.To = "[EMAIL PROTECTED]"
            objmail.Subject = "web mail 2"
            objCOnfig.SmtpServer = sSMTPServer
            objCOnfig.Send(objmail)
            MsgBox("Web Mail2. Sent!!")
        Catch err As Exception
            err.Source = "web mail 2"
            writetolog(err)
            MsgBox(err.Message & vbCrLf & "++++++++++++++" & vbCrLf &
err.ToString)
        End Try
    End Sub

Outlook Code
==========
    Private Sub sendoutlookmail()
        Dim objOutlook As Outlook.Application
        Dim objNameSpace As Outlook.NameSpace
        Dim objInbox As Outlook.MAPIFolder
        Dim objMail As Outlook._MailItem
        Try
            objOutlook = New Outlook.Application()
            'Get the MAPI reference
            objNameSpace = objOutlook.GetNamespace("MAPI")
            objNameSpace.Logon("", "", True, True)
            'Pick up the Inbox
            objInbox =
objNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

            objMail = objInbox.Items.Add
            With objMail
                .Subject = "is this kool or what"
                .To = "[EMAIL PROTECTED]"
                .Send()
            End With
            MsgBox("donenologon")

        Catch err As Exception
            err.Source = "outlook mail"
            writetolog(err)
            MsgBox(err.Message & vbCrLf & "++++++++++++++" & vbCrLf &
err.ToString)
        End Try
        objMail = Nothing
        objInbox = Nothing
        objNameSpace = Nothing
        objOutlook = Nothing
    End Sub

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 12, 2002 12:52 AM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Web Mail


Web.Mail does depend upon CDO. If you do not wish to depend upon CDO for
SMTP client capabilities, then you can purchase
something like
IPWorks for .Net
http://www.nsoftware.com/products/showprod.aspx?part=IPN5-A

or you can try an open source solution like OpenSmtp
http://sourceforge.net/projects/opensmtp-net

I have used both successfully, and actually prefer OpenSmtp a bit more
from
a technical standpoint. However, IPWorks is
a good investment if you need a good suite of .Net IP protocol
implementations.
---------------------------
Justin E. Pitts, Sr Programmer Analyst
PC Applications Development
BIG LOTS -- World's Best Bargain Place

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to