VB.NET get mail server

S

scorpion53061

Fergus,

Do you have an idea of how one might programmatically search for a "SMTP
Server" subkey through the entire registry?
If we can do this, then it will not matter what email client the user
has.....
 
F

Fergus Cooney

Hi Scorpion,

I sure do!! Work on something else today and watch this space. ;-))

Coming soon to a thread near you:

Public Class RegistrySearch (sValueName As String)

Regards,
Fergus
 
F

Fergus Cooney

Hi again Scorpion,

Cor has just asked me <why> you want the SMTP Server info. And, you know,
I haven't asked you yet! So what's the question behind the question, as it
were?

Regards,
Fergus
 
S

scorpion53061

Is Cor suspicious of me? That is ok I probably would be too......

Out customer software (which I built as I take a bow :) None of the other
guys in my office could do it) in the past has used a smtp mailer to do
confirmation of orders with our customers and to provide email back and
forth between the various departments at my company and the customer.

(This software also provides pricing, stock status and order entry in real
time on an AIX server for those of you wondering what else it does.........)

I always had the user enter the information and it was saved to an XML file
and retrieved when the program started up.

The only problem with that is a lot of the customers (we area plumbing and
electrical distribution company) are well not knowledgeable when it comes to
these things. So the boss wanted the program to automatically detect their
smtp information. Of course I said I could do it thinking a simple registry
query would work.

But little did I know.......

If you have any doubts as to my intentions do this.....
http://www.jjkoepsell.com/downloads.html and download the software it is at
the bottom of the page called "JJ Koepsell Customer Software" or click here
to start the install
(http://63.252.11.73/softdownloads/JJ Koepsell Customer Software.exe)

After doing so email me ([email protected] ) and I will send
you a username and password. Actually it would be fun to have you guys do
this and pick on me for everything I have done wrong in this application. :)
 
C

Cor

Hi Scorpion,

I was not suspicious, Fergus did not tell you, but in another thread Fergus
said he was very busy with your problem.

I saw this thread, (I followed it more than you know) and I saw nothing in
it which described your problem, and I thought, maybe there is another way
to get an solution.

I did tell that to Fergus, and he said, you are right, normaly I ask that
and now I have not done, I was fixed on the point of registry.

I told him that if there is a javascript in a html page you can as far as I
know open every mailprogram. So why not using that. Fergus thinks it is not
possible and I leave it first to him, I think he is turning around in his
bed now with your problem, maybe he send a message in some hours.

:)

Cor
 
S

scorpion53061

Great we are on the same page then.

I hope I have not inconvienced Fergus too much.

Your web page idea what thread was that covered in?
 
S

scorpion53061

HI all just so you know........

I figured out where outlook stored the registry information on outlook
users.......kind of...

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles\Outlook

But interpreting the results of is problematic as you will see.
 
C

Cor

Hi Scorpion,

In that thread you was answering, there was something that I had send in
using JavaScript in a Window program, I can send it here or you can just
take it there?

What you want?

Cor
 
S

scorpion53061

Okay possible scenario.

If no SMTP value is detected in the Outlook Express arena we talked about
this weekend we can check outlook under the Windows Messaging Subsystem key
using HKEY_USERS\insert numbers here but should end with-500

HKEY_USERS\number ending in -500\Software\Microsoft\Windows
NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook

1. It seems in the windows messaging subsystem there will be one subkey that
will contain the LastChange and NextAccout subkeys. It would be necessary to
loop through all folders under the Outlook subkeys to determine which one.

2. Once that is found the subkey with the highest number is selected(e.g.
000003 or whatever).

3. The value of the SMTP Server is grabbed.

4. Now we have to convert the BINARY format to something useable. Not a clue
there.........The value we would need is present but how to get rid of all
the junk along with it....
 
S

scorpion53061

send it to (e-mail address removed)

The attachment never arrived in the other thread.
 
C

Cor

Hi Scorpion,
It was not an attachment just this
For a webform
\\\
Dim str As String
str = "<script language=javascript> {window.open('http://www.google.com');}
</script>"
RegisterStartupScript("Startup", str)
///
For a windowform (author HKW) I think he did forget it :))
\\\
AxWebBrowser.Navigate("about:<html><body
onload=javascript:window.external.addFavorite('" + textbox1.Text +
"')></body></html>")
///
I think you would use the one beneath. This was to open the favorite menu.

I am not absolute sure if it will work, but when Fergus does not find it, I
go look for it also tomorrow. I have only still few free time today, but
tonight I am again home and will look..

OK?

Cor
 
C

Cor

Hi Scorpion,
Can you try if this is something for you?

You have to set a reference to the com microsoft.webbrowser

\\\\
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxWebBrowser1.Navigate2("mailto:[email protected]?subject=Maildemo&body=The
Scorpion and the man of Fer")
End Sub
////
Keep track that there are no spaces in Maildemo&body

Cor
 
F

Fergus Cooney

Hi Cor,

In the message where I said I think it's not possible, I had a ROFL.

That's because I've written two long posts describing how Url Protocols
(including mailto:) work I've also posted so many snippets that send mail
using mailto: that I've lost count.

So I was being very tongue-in-cheek when I said it couldn't be done.
;-)

The routine below will put a message into the email program but not do the
actual send. This is left to the User, after they've done any editing that
they might want to do.

Regards,
Fergus

<code>
'A reference to System.Web may be necessary
'in the Project for this Import to work.
Imports System.Web.HttpUtility

Public Sub StartDefaultMail (sTo As String, _
Optional sSubject As String = "", _
Optional sMessage As String = "")
Try
sTo = UrlEncode (sTo)
sSubject = UrlEncode (sSubject)
sMessage = UrlEncode (sMessage)
Process.Start ("mailto:" & sTo & "?subject=" _
& sSubject & "&body=" & sMessage)

Catch e As Exception
MsgBox ("Couldn't start default email application" _
& vbCrLf & e.Message)
'or
Throw New Exception ("Couldn't start default email app", e)
End Try
End Sub
</code>
 
F

Fergus Cooney

Hi Scorpion,

I'm still not clear on this. Which of the following is/are correct?

1 You need to know the Smtp Server so that you can use it with the .NET
mail classes.

2 You need to know the Smtp Server so that you can use it with
something else.

3 You want to compose <and> send a mail independantly of the User.

4 You want to create a mail message and then stick it into the default
email application so that the User can finish it off and send it

5 Something else.

Regards,
Fergus
 
F

Fergus Cooney

Hi Scorpion,

And as a separate topic: Any trouble I'm taking with this serves me too,
so no worries there. ;-)

Do you still want the option of searching the Registry? I have a raw
searcher done but taking it beyond a snippet will require more work (again,
don't worry, I want this for myself, too).

Basically, a registry search takes a long time. If you do two searches in
a row that doubles it (naturally) but doing two searchges together is much
better because most of the time is spent opening and closing Registry Keys and
getting the name lists.

The other aspect is that the long time required means that a threaded
approach with progress reporting is preferable.

So if you still want it, can you hold on while I knit these all together?
And if so, could you give me details of the specific searches that you would
want to do. So far I've got
Search for all values named 'Smpt Server'.
Find all Keys under HKEY_USERS which ending with '-500'.

Are there any others? Do you need to search for value <data> as well as
names?

Regards,
Fergus
 
C

Cor

Hi Fergus,

And I was very suprised you said that, so I thought let me wait, because I
knew that you did something for Nick a long while ago.

But I saw nothing so I made something this afternoon here.

Now Scorpion has an alternative so he can choose if he want that solution.

But although my solution looks shorter, I would use yours, because with what
I made you have to distribute the SHdoc to (You understand I write this also
for Scorpion).

:)
Cor
 
F

Fergus Cooney

Hi Cor,

Understood, mate, my previous message was also partly for Scorpion ;-)
but this one's just for you.

I have to say, Cor:
Thank you, thank you, thank you.

Without intending to, you have solved a most hair-pulling problem for me.
For a long while now, back as far as Charles' UserControl/WebBrowser issue and
before, I've been unable to actually <use> a Web Browser Control. I could
<create> one easily enough. It would sit on my Form looking all white and
blank and ready for some Html. But there were no browsing methods!??

In your post you said distribute the 'ShDoc' and I thought - 'don't you
mean the AxBrowser?'. That's what I've had all this time and I thought it must
have got broken somehow. It seems to have no browse capability at all. But
yours is working for you and mine's not so ShDoc must mean something.

Thus inspired, I took out the AxBrowser and all references, removed it
from the ToolBox, deleted all the Interop wrappers and started again. There
under Add References all I had was AxBrowse, as before, but then appeared the
ShDocVw which I'd skipped past so many times because I was thinking of Windows
Explorer and the <List> View and didn't recognise that it's the Browser!!.
Haha!!

I'm a happy bunny again. ;-))

Regards,
Fergus
 
S

scorpion53061

I am working on something similar.......

Sorry I was buried for a couple days at work and didnt get back here as much
as I would liek

I want to do the registry thing because I think it would be a powerful addin
for a lot of apps I build.
 
S

scorpion53061

was very good.......this works but we have a custom mailer I built he was
wanting that used with.....A form with a textbox for them to type in and
attach a file.
If I could suppress the email program and grab the server name then we would
be on to something
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

can't send or receive emails- 2
can't send mail 1
Trouble Setting up .... 1
Balance Due??? 12
error in receiving messages. 1
Can't send messages 7
error# 0x800CCC0E 1
I can receive e-mail but i can't SEND 17

Top