Home All Groups Group Topic Archive Search About
Author
27 Jan 2006 4:41 PM
JJ
Whats the most compatilbe way of sending an email ?- I need to consider that
the OS may be win 98/win NT/Win 2000/winXP.

I was constructing a mailto command, but the contents of the text file I am
using as the subject is too long and gets cut off. I therefore need a method
that doesn't use the limitations of mailto (in terms of the length of the
subject text) or allows me to add the text file as an attachment.

I am using VB 2003. I don't mind assuming that the using has outlook if that
is the only way.

TIA

Author
30 Jan 2006 12:30 PM
C-Services Holland b.v.
JJ wrote:
Show quoteHide quote
> Whats the most compatilbe way of sending an email ?- I need to consider that
> the OS may be win 98/win NT/Win 2000/winXP.
>
> I was constructing a mailto command, but the contents of the text file I am
> using as the subject is too long and gets cut off. I therefore need a method
> that doesn't use the limitations of mailto (in terms of the length of the
> subject text) or allows me to add the text file as an attachment.
>
> I am using VB 2003. I don't mind assuming that the using has outlook if that
> is the only way.
>
> TIA
>
>

..net has a built in mail thing. Look at the system.web.mail namespace.


--
Rinze van Huizen
C-Services Holland b.v
Author
30 Jan 2006 1:51 PM
JJ
Rinze - thanks for replying.

As far as I can see the system.web.mail namespace will only work if you
specify an SMTP server or are running on windows 2000. I have no access to
an smtp server for the app and don't know the one the end user will have
access to. [Will it use the users default SMTP server if none is specified
on a non windows 2000 system?] I need to open a fresh email message using
their default email client (sorry should have been more specific) before
sending. The system.web.mail namespace seems to send the mail 'silently' if
I understand it correctly.

I only need to send textual information - but its more than a mailto:
command can cope with.

Please correct me if my understandung of the system.web.mail namespace is
incorrect.


Show quoteHide quote
"C-Services Holland b.v." <c**@REMOVEcsh4u.nl> wrote in message
news:M9CdnUTjd_XDmEPenZ2dnUVZ8qednZ2d@zeelandnet.nl...
> JJ wrote:
>> Whats the most compatilbe way of sending an email ?- I need to consider
>> that the OS may be win 98/win NT/Win 2000/winXP.
>>
>> I was constructing a mailto command, but the contents of the text file I
>> am using as the subject is too long and gets cut off. I therefore need a
>> method that doesn't use the limitations of mailto (in terms of the length
>> of the subject text) or allows me to add the text file as an attachment.
>>
>> I am using VB 2003. I don't mind assuming that the using has outlook if
>> that is the only way.
>>
>> TIA
>>
>>
>
> .net has a built in mail thing. Look at the system.web.mail namespace.
>
>
> --
> Rinze van Huizen
> C-Services Holland b.v
Author
31 Jan 2006 11:29 AM
C-Services Holland b.v.
JJ wrote:

Show quoteHide quote
> Rinze - thanks for replying.
>
> As far as I can see the system.web.mail namespace will only work if you
> specify an SMTP server or are running on windows 2000. I have no access to
> an smtp server for the app and don't know the one the end user will have
> access to. [Will it use the users default SMTP server if none is specified
> on a non windows 2000 system?] I need to open a fresh email message using
> their default email client (sorry should have been more specific) before
> sending. The system.web.mail namespace seems to send the mail 'silently' if
> I understand it correctly.
>
> I only need to send textual information - but its more than a mailto:
> command can cope with.
>
> Please correct me if my understandung of the system.web.mail namespace is
> incorrect.
>
>
> "C-Services Holland b.v." <c**@REMOVEcsh4u.nl> wrote in message

I understand your problem. In essence I'm trying to do the same and ran
into the mailto limitations. AFAIK it will not use the configured SMTP
server, for that it would have to know where to find those settings of
various mailclients. So I'm resorting to have them enter the SMTP
settings in a configuration screen. It's a bit of a hassle (for the
user) but so far I don't have any choice.

--
Rinze van Huizen
C-Services Holland b.v
Author
31 Jan 2006 12:13 PM
JJ
Hi Rinze.

That seems to be the only solution. I think I'll do the same - only also
give the option of attempting to open an outlook mail message. The send mail
function is important to the whole function of the program so I have to make
sure they can do it some way.

Below is the Outlook code if its of any use to you. If Outlook is installed
it'll create an instance of it and construct a mail message. It'll also
clean up after itself by closing Outlook if it's instance was created by the
app.

Thanks for your help.

----





Global vars:
-------------
Private myOutlookApp As Outlook.Application 'for outlook email
Private MyOutlookAppKillMe As Boolean = True 'for outlook email


E-mail Function:
----------------
Private Function OpenEmail(ByVal EmailAddress As String, Optional ByVal
Subject As String = "", Optional ByVal Body As String = "")
'lauches a new intance of Outlook if it isn't running already, and
constructs and email message. The form closing routine closes Outlook if
this program
'launched it (i.e. it wasn't running already). If no outlook instance is
present or created, then outlook isn't installed and the relevent menu
options
' are therefore disabled.

Try
    myOutlookApp = CType(GetObject(, "Outlook.Application"),
Outlook.Application)
    MyOutlookAppKillMe = False
Catch ex As Exception
    'if not then launch it
    If myOutlookApp Is Nothing Then
    myOutlookApp = New Outlook.Application
    MyOutlookAppKillMe = True
    End If
End Try
'if myOutlookApp is nothing then Outlook isn't installed
If myOutlookApp Is Nothing Then
    MessageBox.Show("Outlook is required for this function. .", "Outlook Not
Available", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    ToolBar1.Buttons.Item(17).Enabled = False
    mnuEmail.Enabled = False
    Exit Function
Else
    Try
        Dim thisEmail As Outlook.MailItem
        Me.Cursor = Cursors.WaitCursor
        thisEmail =
DirectCast(myOutlookApp.CreateItem(Outlook.OlItemType.olMailItem),
Outlook.MailItem)
        With thisEmail
            .To = EmailAddress.Trim()
            .Subject = Subject.Trim()
            .BodyFormat = Outlook.OlBodyFormat.olFormatPlain
            .Body = Bodystring
           .Display()
        End With
        Me.Cursor = Cursors.Default
    Catch ex As Exception
        MessageBox.Show("Outlook encountered a problem when trying to
construct the email. ", "Outlook Error", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
    End Try

End If
End Function




Then on closing the app, add the code:
--------------------------------------

'Outlook checks:
If MyOutlookAppKillMe = True Then 'Check if this app had started Outlook
    If Not myOutlookApp Is Nothing Then
        myOutlookApp.Quit() 'if outlook is running then close it
        myOutlookApp = Nothing
    End If
End If

[I can't take credit for all this code - it was based on someone elses, but
I can't for the life of me find who it was.]


Show quoteHide quote
"C-Services Holland b.v." <c**@REMOVEcsh4u.nl> wrote in message
news:sd2dnSCvO5c_1ULeRVnyjA@zeelandnet.nl...
> JJ wrote:
>
>> Rinze - thanks for replying.
>>
>> As far as I can see the system.web.mail namespace will only work if you
>> specify an SMTP server or are running on windows 2000. I have no access
>> to an smtp server for the app and don't know the one the end user will
>> have access to. [Will it use the users default SMTP server if none is
>> specified on a non windows 2000 system?] I need to open a fresh email
>> message using their default email client (sorry should have been more
>> specific) before sending. The system.web.mail namespace seems to send the
>> mail 'silently' if I understand it correctly.
>>
>> I only need to send textual information - but its more than a mailto:
>> command can cope with.
>>
>> Please correct me if my understandung of the system.web.mail namespace is
>> incorrect.
>>
>>
>> "C-Services Holland b.v." <c**@REMOVEcsh4u.nl> wrote in message
>
> I understand your problem. In essence I'm trying to do the same and ran
> into the mailto limitations. AFAIK it will not use the configured SMTP
> server, for that it would have to know where to find those settings of
> various mailclients. So I'm resorting to have them enter the SMTP settings
> in a configuration screen. It's a bit of a hassle (for the user) but so
> far I don't have any choice.
>
> --
> Rinze van Huizen
> C-Services Holland b.v