sending emails

Marta

Registered User.
Local time
Today, 01:02
Joined
Apr 8, 2011
Messages
16
Hi,
I have a problem with sending emails. I have hyper-link field called email in my database and I would like to send email to email address after I click on the button. Here is the code I use:

Code:
Dim email As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
email = Me.email
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
    .To = email
    .display 
    .send
End With

objOutlook.Quit
Set objEmail = Nothing

But it loads not just the email address but also the displayed text. So it looks like this:
To: marta#mailto:marta33@gmail.com#
And I can't send it this way. How can I solve this problem?
Thanks for answers.
 
The best fix is to remove the hyperlink from your table and just set the field property to text instead and run an update query to remove the "#" from the email field.

or this should work:

Code:
Dim email As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
email = [COLOR=red]Replace([/COLOR]Me.email[COLOR=red], "#","")[/COLOR]
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
    .To = email
    .display 
    .send
End With

objOutlook.Quit
Set objEmail = Nothing

JR
 

Users who are viewing this thread

Back
Top Bottom