Results 1 to 2 of 2

Thread: Mail Problem...plz Help

  1. #1

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Mail Problem...plz Help

    Hi,

    Here is a code given by someone for sending a simple mail, but the code is giving a compiler error "User-defined type not defined", someone suggested to add reference of Microsoft Outlook xxx type library where xxx is the version of Outlook i am using. But still, the problem is same.

    So, can anyone correct it or just give me another code for sending a simple mail.

    Hope u people help.

    Thanx

    Here is the code :

    Private Sub Command1_Click()

    Dim olapp As New Outlook.Application
    Dim olMail As Outlook.MailItem
    Dim olAttachment As Outlook.Attachments

    ' Create a new mail object form the
    ' Outlook98 Application object

    Set olMail = olapp.CreateItem(olMailItem)
    Set olAttachment = olMail.Attachments

    olMail.To = "[email protected]"
    olMail.Subject = "Test Message"
    olMail.Body = "Hello, this is a test message"

    ' olMail.Attachment.Add "FileName1"
    olMail.Send

    End Sub

  2. #2
    Addicted Member Sully's Avatar
    Join Date
    Nov 2002
    Location
    Lost in the far recesses of one's own mind.
    Posts
    165
    This works for me...


    VB Code:
    1. Dim outmail As Object
    2.  
    3.    Set outmail = CreateObject("Outlook.application")
    4.          On Error GoTo Mailerr
    5.          With outmail.CreateItem(outMailItem)
    6.              
    7.                .Recipients.Add   "[email protected]"
    8.                .Subject = txtSubject
    9.                .Body = txtBody
    10.                .Attachments.Add FileAttachment
    11.                .Send
    12.          End With
    Disclaimer:

    * The preceding message was in no means meant to be critical, mean spirited, insincere, or facetious.

    Disclaimer for disclaimer:

    The preceding disclaimer may in fact be facetious in nature.

    Thanks,
    Jim

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