CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    98

    [RESOLVED] Send email VB6

    Hello all

    I'm trying to modify this part of the code:

    Code:
    'Set OLRecipient = OLNameSpace.CreateRecipient("[email protected]")

    Instead of putting the email in the code, i would like to use a text1 where i can put a custom address, directly in my Form4.email_le_vignoble.Text.

    how can i do that?

    I have tried like this:
    Code:
    	
    
    Set OLRecipient = OLNameSpace.CreateRecipient.Form4.email_le_vignoble.Text

    But i have the compile error " Argument not Optional"

    Thanks again

    Thanks again for your help

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Send email VB6

    Code:
    Dim strEmail as String
    strEmail   =  """ & Form4.email_le_vignoble.Text & """
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2009
    Posts
    98

    Re: Send email VB6

    Hello dglienna
    This is perfect. Now it working perfectly

    Code:
    Dim OLApp As Outlook.Application
    Dim OLNameSpace As Outlook.Namespace
    Dim OLRecipient As Outlook.Recipient
    Dim OLAppt As Outlook.AppointmentItem
    Dim strEmail As String
    
    
    
    Set OLApp = New Outlook.Application
    Set OLNameSpace = OLApp.GetNamespace("MAPI")
    OLNameSpace.Logoff
    OLNameSpace.Logon "Logon Name", "Password", False, True
    
    'emai
    strEmail = """ & Form4.email_le_vignoble.Text & """
    Set OLAppt = OLApp.CreateItem(olAppointmentItem)

    Thanks again for your help

  4. #4
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Smile Re: [RESOLVED] Send email VB6

    You can go on with this following code .it works like a charm for me .really nice code to send email using Ms outlook .
    Code:
    Option Explicit
    Private Sub Form_Load()
    Call SendMailUsingOutLook
    End Sub
    Public Sub SendMailUsingOutLook()
    Dim objOutlook As Object
    Dim objOutlookMsg As Object
    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(0)
    With objOutlookMsg
       .To = "[email protected]"
       .Cc = "[email protected]"
       .Subject = "Sending Emails using Outlook."
       .Body = "find this email"
       .HTMLBody = "HTML version of message"
       .Attachments.Add ("c:\imp.txt")
       .Send 'Let´s go!
    End With
    Set objOutlookMsg = Nothing
    End Sub:wave:

  5. #5
    Join Date
    Aug 2009
    Posts
    98

    Re: [RESOLVED] Send email VB6

    Hello firoz.raj. Let me try this and i will let you know the result

    Thanks

  6. #6
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Smile Re: [RESOLVED] Send email VB6

    before i post i have checked the code .this code working like a charm.

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

Featured