Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strEmail As String

Status
Not open for further replies.

Lunatic

Technical User
May 8, 2006
405
US
I'm stuck again with trying to modify some code I'm borrowing from here... I'm trying to get Access send a message with the TO: address drawn from the field txtToEmail but that doesn't seem to be working...

Code:
Private Sub cmdEmailTrackingNumber1_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

strEmail = txtToEmail

strBody = strBody & "Atraining package has been sent to you, please see the tracking number and description below for more details"
strBody = strBody & "Tracking Number: " & txtTrackingNumber1
strBody = strBody & "Description: " & txtTrackingNumber1Description

With objEmail
    .To = strEmail
    .Subject = "Training Shipment Tracking Information"
    .Body = strBody
    .Send
End With

Set objEmail = Nothing


Exit Sub
End Sub
The
[highlight].To = strEmail[/highlight]
Doesn't seem to be drawing the e-mail from field I want it to with this early bit
[highlight]strEmail = txtToEmail[/highlight]

I keep recieving a runtime error with a set of strange numbers and a message that reads "There must be at least on name or distribution list in the To, CC, or BCC box".

The debug highlights
[highlight].Send[/highlight]

I'm running Access 2002 and had an early problem with some references not being turned on, but I've activated both of the Outlook References for the system... Did I miss one?

Any suggestions, ideas, or places to look are much appriciated!

***************************************
Have a problem with my spelling or grammar? Please refer all complaints to my English teacher:
Ralphy "Me fail English? That's unpossible." Wiggum
 
What is txtToEmail ? a populated TextBox in the same form as cmdEmailTrackingNumber1 ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV!

The txt was added to each field in the example I was using so I thought it needed to be added. I removed the txt (field name is ToEmail) and it worked great!

Thank you again!

***************************************
Have a problem with my spelling or grammar? Please refer all complaints to my English teacher:
Ralphy "Me fail English? That's unpossible." Wiggum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top