Results 1 to 32 of 32

Thread: how to make lable of address and how to connect vb to outlook for send email

Hybrid View

  1. #1
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: how to make lable of address and how to connect vb to outlook for send email

    Try this:
    VB Code:
    1. 'In your project go to References and click Microsoft Outlook 8.0/11.0 Object Library.
    2.  
    3. ' make sure a reference to the Outlook object is set
    4. ' place the following code in a command button click event
    5. Private Sub cmdSendMail_Click()
    6.     Dim objOutlook As Outlook.Application
    7.     Dim objMailItem As Outlook.MailItem
    8.     Set objOutlook = New Outlook.Application
    9.     Set objMailItem = objOutlook.CreateItem(olMailItem)
    10.     With objMailItem
    11.         .To = "ToAddress"  'recipient's address
    12.         .Subject = "subject"  'subject box content
    13.         .Body = "email message"  ' message goes here
    14.         .Attachment = "c:\path\file.txt"    ' attach any files here
    15.         .Send
    16.     End With
    17.     Set objMailItem = Nothing
    18.     Set objOutlook = Nothing
    19. End Sub
    CS

  2. #2

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: how to make lable of address and how to connect vb to outlook for send email

    first this massage
    a program throwing outomaticall email do u want to allow it yes or no
    occuring

    on clicking no error occuring application defined or object defined error

    on clicking yes error occuring outlook does not recnoze one or more name

    on this code
    VB Code:
    1. .Send

    and object does not this property of meathod error here

    VB Code:
    1. .Attachment = "c:\path\file.txt"    ' attach any files here

    three error occuring i m using ur last post this one

    VB Code:
    1. Private Sub cmdSendMail_Click()
    2.     Dim objOutlook As Outlook.Application
    3.     Dim objMailItem As Outlook.MailItem
    4.     Set objOutlook = New Outlook.Application
    5.     Set objMailItem = objOutlook.CreateItem(olMailItem)
    6.     With objMailItem
    7.         .To = "ToAddress"  'recipient's address
    8.         .Subject = "subject"  'subject box content
    9.         .Body = "email message"  ' message goes here
    10.         .Attachment = "c:\path\file.txt"    ' attach any files here
    11.         .Send
    12.     End With
    13.     Set objMailItem = Nothing
    14.     Set objOutlook = Nothing
    15. End Sub

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