Results 1 to 5 of 5

Thread: Email Question

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    33
    Hi

    I tried the following code listed under VB-World Internet Programming. It seems to place all the input(To:, Subject: and Body: ) in the To: field...

    Any Ideas??

    Thanks

    Gregg




    Call SendMail("[email protected]", "Overdue Payment", _
    "Your current bill is: $105.09. Pay up!", _
    "[email protected]", "[email protected]")

    CODE:

    Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hwnd As Long, _
    ByVal lpOperation As String, ByVal lpFile As String, _
    ByVal lpParameters As String, ByVal lpDirectory _
    As String, ByVal nShowCmd As Long) As Long

    Private Const SW_SHOWNORMAL = 1

    Public Sub SendMail(Optional Address As String, _
    Optional Subject As String, Optional Body As String, _
    Optional CC As String, Optional BCC As String)

    Dim strCommand As String

    'Build up the mail string
    If Len(Subject) Then strCommand = "&Subject=" & Subject
    If Len(Body) Then strCommand = strCommand & "&Body=" & Body
    If Len(CC) Then strCommand = strCommand & "&CC=" & CC
    If Len(BCC) Then strCommand = strCommand & "&BCC=" & BCC

    'Replace the first ampersand, if any,
    'with a question mark
    If Len(strCommand) Then
    Mid(strCommand, 1, 1) = "?"
    End If

    'Add mailto: command and main e-mail
    'address to the command string
    strCommand = "mailto:" & Address & strCommand

    'Execute command via the API
    Call ShellExecute(Me.hwnd, "open", strCommand, _
    vbNullString, vbNullString, SW_SHOWNORMAL)

    End Sub






  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The code works on my computer. No problems at all.

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Posts
    117
    What mail program does is open when you run the program ?

  4. #4
    Lively Member
    Join Date
    Aug 2000
    Posts
    117
    Also is it possible to go one step further and send the mail automatically?

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I use Outlook 2000. But I know that it works with Outlook Express as well.
    If you want to send e-mail you could have a look at the MAPI controls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width