Email from Within VB6


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: Email from Within VB6

  1. #1
    Join Date
    Feb 2005
    Location
    Brisbane, Australia
    Posts
    13

    Exclamation 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

  2. #2
    Join Date
    May 2008
    Posts
    37
    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

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    What do you have so far?
    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

  4. #4
    Join Date
    Feb 2005
    Location
    Brisbane, Australia
    Posts
    13
    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

  5. #5
    Join Date
    May 2008
    Posts
    37
    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

  6. #6
    Join Date
    Feb 2005
    Location
    Brisbane, Australia
    Posts
    13
    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

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote 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

  8. #8
    Join Date
    Feb 2005
    Location
    Brisbane, Australia
    Posts
    13
    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

  9. #9
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    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

  10. #10
    Join Date
    Feb 2005
    Location
    Brisbane, Australia
    Posts
    13

    Thumbs down

    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

  11. #11
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote 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

  1. Stand alone email client for pop3 email
    By luckyluk in forum VB Classic
    Replies: 1
    Last Post: 03-18-2006, 05:36 PM
  2. Speaking of strings...
    By Harlow in forum .NET
    Replies: 246
    Last Post: 10-26-2002, 12:30 AM
  3. convert email messages to tasks utomatically
    By Anthony Meo in forum Enterprise
    Replies: 0
    Last Post: 01-15-2002, 04:44 PM
  4. Replies: 0
    Last Post: 04-19-2001, 11:48 AM
  5. 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center