-
Email from Within VB6
Hi All,
My problem is different to all other email requirements from within VB6.
I need to trigger an email from within VB6 (regardless of the user's mail client - Outlook, Thunderbird, etc.) so that the email program pops up with an outgoing message.
I want the following fields to be pre-populated:
To:
From:
Subject:
Message:
The email should be in HTML format and I need to insert an image in the Message Body.
At this point the user should be able to edit the email before sending.
Hope someone can help.
Thanks in advance,
Alan
-
have you tried vbsendmail ?
thats what i have used to trigger emails to inform specific users of tasks from my vb app.
BASED FROM YOUR POSTS, I HAVE EXAMINED YOUR BEHAVIORAL PATTERN AND I SAW YOUR BRAIN'S TWO SIDES : LEFT & RIGHT, AND I SAW THAT ON THE LEFT SIDE THERE'S NOTHING RIGHT WHILE ON THE RIGHT SIDE THERE'S NOTHING LEFT
-
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Hi Guys,
Thanks for your replies.
Does VBSendMail actually popup the default email app for the user? It is very important that this happens and they have to click the Send button themselves. We have 1,700 clients (Over 5,000 users) who use our application and it is important that they have the opportunity to view the email before sending.
At this point the only thing I have to use is ShellExecute, which I can get to work fine for all things I require except inserting an image in the body of the email.
Thanks for your help.
Alan
-
vbSendMail does not popup the default email app. It communicates directly to your mail host.
I downloaded the ZIP file from www.freevbcode.com and it came with examples for sending ordinary mails to bulk mail (w or w/o attachments too!)
I just worked my way from there on.
Cheers !!!
BASED FROM YOUR POSTS, I HAVE EXAMINED YOUR BEHAVIORAL PATTERN AND I SAW YOUR BRAIN'S TWO SIDES : LEFT & RIGHT, AND I SAW THAT ON THE LEFT SIDE THERE'S NOTHING RIGHT WHILE ON THE RIGHT SIDE THERE'S NOTHING LEFT
-
It looks like I will have to do some more research, because I definitely have to have the default email app to popup. I have decided that the insertion of images in the body of the email is not a major issue.
I may have to check the registry for the default email app and have separate code for each app.
Thanks for your help.
Alan
-
 Originally Posted by aliddle
I may have to check the registry for the default email app and have separate code for each app.
This might help in that regard.
Code:
Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
lpType As Long, _
lpData As Any, _
lpcbData As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal samDesired As Long, _
phkResult As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDst As Any, _
pSrc As Any, _
ByVal ByteLen As Long)
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const READ_CONTROL = &H20000
Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE _
Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Private Function FindDefaultMail() As String
'Find the default Email Client in the registry.
Dim ByteBuffer() As Byte
Dim lType As Long
Dim lSuccess As Long
Dim lKey As Long
Dim lLength As Long
Dim sRegSubKey
Dim sRegKeyValue As String
Dim sRegStringValue As String
'Key and Key Value to retrieve.
sRegSubKey = "Software\Clients\Mail"
sRegKeyValue = ""
'Open it
lSuccess = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sRegSubKey, 0, KEY_READ, lKey)
'Get its length
lSuccess = RegQueryValueEx(lKey, sRegKeyValue, 0&, ByVal 0&, ByVal 0&, lLength)
'Initialize the buffer to lLength
ReDim ByteBuffer(0 To lLength - 1) As Byte
'Get the Key Value
lSuccess = RegQueryValueEx(lKey, sRegKeyValue, 0, lType, ByteBuffer(0), lLength)
'Initialize to lLength
sRegStringValue = String$(lLength, 0)
'Copy memory from the byte array to the string buffer.
CopyMemory ByVal sRegStringValue, ByteBuffer(0), lLength - 1
'Close the open Key
RegCloseKey lKey
'Set the value of the function to the retrieved Key Value
FindDefaultMail = sRegStringValue
End Function
Private Sub Command1_Click()
Dim MyDefaultMail As String
MyDefaultMail = FindDefaultMail
MsgBox MyDefaultMail
End Sub
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Thanks Hack,
I will have a look at that. Would it be better to a registry check on "MailTo", because this would indicate the default email client?
Alan
-
I suppose you could try that...I would want to test it on machines with several different mail clients before I would try it however.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Hi All,
I have given up!
I have researched everything and can't find any way to do what I want to do.
I certainly don't want to have to write a whole email client that does formatting and everything that existing email clients can do, just so my clients can create professional emails. Then there would be possible issues ensuring that these messages are actually saved to the correct sent folders (for legal reasons) in a way that the default email client can read properly when required.
I can't believe that there isn't a simple standard interface to email clients that works across all email clients????
Thanks for all your help.
Alan
-
 Originally Posted by aliddle
I can't believe that there isn't a simple standard interface to email clients that works across all email clients????
Everyone wants their own little chunk of the email action. If there were something like this, I suspect a lot of other email clients would fall by the wayside.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Similar Threads
-
By luckyluk in forum VB Classic
Replies: 1
Last Post: 03-18-2006, 05:36 PM
-
Replies: 246
Last Post: 10-26-2002, 12:30 AM
-
By Anthony Meo in forum Enterprise
Replies: 0
Last Post: 01-15-2002, 04:44 PM
-
By FM in forum Enterprise
Replies: 0
Last Post: 04-19-2001, 11:48 AM
-
By Mark Burns in forum .NET
Replies: 24
Last Post: 02-09-2001, 12:18 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks