Results 1 to 12 of 12

Thread: hyperlink

  1. #1

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    Post hyperlink

    Does anyone have some code that i could use in one of my projects that when clicked will bring up a webpage in explorer/netscape or send an email in a program like outlook?
    Thanks
    Tom

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Open A Web Page

    VB Code:
    1. 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
    2.  
    3. Private Sub Command1_Click()
    4.    Dim OpenPage As Long
    5.      OpenPage = ShellExecute(Form1.hwnd, "Open", "http://www.vbexplorer.com",
    6.      0&, 0&, 0&)
    7. End Sub

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Send An EMail

    VB Code:
    1. Private Sub SendMailMessage(DisplayMsg As Boolean, Receiver As String, Optional
    2.     AttachmentPath)
    3.     Dim objOutlook As Outlook.Application
    4.     Dim objOutlookMsg As Outlook.MailItem
    5.     Dim objOutlookRecip As Outlook.Recipient
    6.     Dim objOutlookAttach As Outlook.Attachment
    7.     Dim CallDescription As String
    8.  
    9. ' Create the Outlook session.
    10.     Set objOutlook = CreateObject("Outlook.Application")
    11.  
    12. ' Create the message.
    13.     Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    14.  
    15.     With objOutlookMsg
    16. ' Add the To recipient(s) to the message.
    17.         Set objOutlookRecip = .Recipients.Add(Receiver)
    18.         objOutlookRecip.Type = olTo
    19.  
    20. ' Add the CC recipient(s) to the message.
    21.         Set objOutlookRecip = .Recipients.Add("an other person")
    22.         objOutlookRecip.Type = olCC
    23.  
    24. ' Set the Subject, Body, and Importance of the message.
    25.         .Subject = "Replace this String With your subject Or variabele"
    26.  
    27.         .Body = "replace this String With your subject Or variabele"
    28.         .Body = .Body & vbCrLf & "In this manner you can create a body larger than 256 characters"
    29.  
    30. ' Add attachments to the message.
    31.         If Not IsMissing(AttachmentPath) Then
    32.             Set objOutlookAttach = .Attachments.Add(AttachmentPath)
    33.         End If
    34.  
    35. ' Resolve each Recipient's name.
    36.         For Each objOutlookRecip In .Recipients
    37.             objOutlookRecip.Resolve
    38.         Next
    39.  
    40. ' Should we display the message before sending?
    41.         If DisplayMsg Then
    42.             .Display
    43.         Else
    44.             .Send
    45.         End If
    46.  
    47.     End With
    48.  
    49.     Set objOutlook = Nothing
    50. End Sub

  4. #4

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    cheers Hack
    Last edited by TomGibbons; Sep 22nd, 2003 at 11:16 AM.

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    If you don't need to actually send the email from your app, and since not everyone has Outlook installed (I mean configured)
    Than you propably just want to open the default email program, with a specified emailadress, than use this code:

    VB Code:
    1. 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
    2.  
    3. Private Sub Command1_Click()
    4.    Dim OpenPage As Long
    5.      OpenPage = ShellExecute(Form1.hwnd, "Open", "mailto:[email protected]",
    6.      0&, 0&, 0&)
    7. End Sub

    And in VB.NET this would be:
    VB Code:
    1. System.Diagnostics.Process.Start("mailto:[email protected]")

    Good Luck!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Hey Jop: Using just the "Open", can you specifiy the text that goes into the body of a message, and attach attachments?

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    No, but did I say it could?
    I'm not saying your code is bad or anything, just providing an alternative... the code I posted was just as an example to show the possibilities.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    No, no, no Jop - you misunderstand. I'd like to know if you can do that because if you can, that would be a very cool alternative for folks that don't have Outlook. I don't know if you can. I was wondering if you knew.

  9. #9
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hehe LOL my bad

    I don't think you can do it that way, or wait maybe you can!!
    I remember something doing in HTML, like mailto:[email protected] and than entering the subject...
    altough I can't remember the code right now... I'll have to look it up.

    Sorry for the misunderstanding!

    Edit:

    You can specify a subject by:
    mailto:[email protected]?subject=HEY!
    Last edited by Jop; Feb 15th, 2002 at 03:36 PM.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  10. #10
    Junior Member
    Join Date
    May 2001
    Posts
    28
    Try this:

    Code:
    mailto:[email protected]?subject=My Subject&body=My Body Text&attach="C:\mydir\myfile.ext"
    I know this works with Outlook, not sure about other e-mail clients though.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I would very much like to have someone NOT using Outlook to test Tom_H's code and let us know if it works.

  12. #12

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    i think without outlook, it just popsup loads of internet explorer windows, does anyone eles get this?

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