Hi everyone,
I have included a "Send mail" module in my vb module, but I want to accept the email address from an input box instead of hard-coding the recipients email address because the recipient may be different each given time.
Below is my code:

 Set OutlookApp = CreateObject("Outlook.Application")
 Set OutlookMail = OutlookApp.CreateItem(0)
 OutlookMail.To = "giftxtian@yahoo.com"
 OutlookMail.Subject = "Project Status"
 OutlookMail.Body = "This is VB email test"
 If Len(MailAttach) = 0 Then
    OutlookMail.Attachments.Add MailAttach  '"C:\ProjectStatus.xls"
 End If
 OutlookMail.Display      'To display the email
 OutlookMail.Send         'To send the email

How can I imbed the input box in the above routine?

you will need a textbox, in your form, and set the OutlookMail.To = to the textbox name and put a .text after it.

OutlookMail.To = textboxname.text

I don't want a textbox control on my form. All my codes are embedded in a Command control which the users clicks and the whole process is executed.
Thanks anyway.

is there a posibility to do a look up and use email address from Outlook Address book - using VB6.?

Hi tgif,

In Command Click, before u call the above module use InputBox say,

Public EMailID as String
EMailID = InputBox("Enter EMail ID")
If Trim(EMailID) <> "" Then
   'Call The Send Function
End If
and change this to:
OutlookMail.To = EMailID


Thanks for your contribution. Your code seem pretty efficient.
Enjoy your day.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.