Hi,
I want an email to be sent, which contains a link to the workbook once a user has filled in a userform and clicks a button on the userform. I have the following code:
However, I'm always getting invalid qualifier or variable not defined. Could someone please help? Thanks in advance! =)Dim outapp As Object Dim outmail As Object Set outapp = GetObject("outlook.application") If outapp Is Nothing Then Set outapp = CreateObject("outlook.application") outapp.session.logon Set outmail = outapp.createitem(0) On Error Resume Next With outmail .to = "example@hotmail.com" .cc = "" .bcc = "" .Subject = "Number" & UserForm2.TextBox1.Text .Body = "Hi," & vbCrLf & _ "I need you to verify details below" & vbCrLf & _ "<file:///c:\\NameOfWorkbook>" & vbCrLf & _ "Thanks," & vbCrLf & vbCrLf _ .send .Readreceiptrequested = False End With outmail.display End Sub
The continuation character in
might be to blame. Try removing it."Thanks," & vbCrLf & vbCrLf _
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
It didn't work =(
Now I'm getting:
Run-error
Automation error
invalid syntax
Hello icylemontea,
I am not really familiar with the Mac Excel 2004, other than there are many differences between the PC and Mac, especially in the use of advanced code. I have contacted another moderator who is very familiar with Macs to take a look at your post.
Just so we are all on the same page, do you want to include a hyperlink in the email body or do you want to include the URL text? It was not clear to me which you wanted.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi Leith,
Sorry, I'm actually on a different computer using excel 2010 at the moment.
Regarding the body of the email, I wanted a hyperlink to the excel file.
Thanks for your help
Hello icylemontea,
Please update your profile to include Excel 2010. It will help everybody when answering any questions you have. As for the link, it has to added in HTML, which you can do in Outlook. Instead of Body you have to use htmlBody. The message must be a string that includes the proper HTML tags for formatting and to provide the link.I can code this for you if you want.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
It's rather curious to have the property .Readreceiptrequested
set to False after sending the mail.
I don't know whether it's possible to show the mail after sending it (outlook.display).
I also fear that you didn't put something into 'NameOfWorkbook'
try this:
Sub snb() With CreateObject("outlook.application").createitem(0) .to = "example@hotmail.com" .Subject = "Number" .Body = replace("Hi,#I need you to verify details below#<file:///c:\\" & thisworkbook.name & ">#Thanks,##","#" vbLf) .send End With End Sub
Last edited by snb; 09-12-2010 at 05:31 AM.
Hi,
I changed
toSet outapp = GetObject("outlook.application")
and that seems to have done the trick.Set OutApp = GetObject("", "Outlook.application")
Thanks guys for your help.
Leith, would you mind showing me the coding for .htmlbody?
Thanks a lot!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks