Forum Home
Press F1
 
Thread ID: 78605 2007-04-22 03:05:00 Excel e-mailing spaceman8815 (4112) Press F1
Post ID Timestamp Content User
543126 2007-04-22 03:05:00 Every time I try to send an spreadsheet e-mail through excel (just the body) it doesn't work, i press the e-mail button and nothing happens. Mozilla Thunderbird is my default e-mail program, and i think that excel is not set to open in Thunderbird does anyone know how to set excel 2007 so that it opens a Thunderbird e-mail window? or is it permanently set to only work on Microsoft e-mail programs? as it worked when i had the trail of MS Outlook Express. spaceman8815 (4112)
543127 2007-04-22 07:12:00 MS Office is heavily rigged to work with Microsoft software. If you want to include a table from Excel in an email your best bet is probably to export your spreadsheet to HTML, open the HTML file with your web browser and copy&paste from there to your email body. This is slow but should be effective. I haven't use Thunderbird in a long time but hopefully you should be able to paste HTML into the email. You could also export to tab-separated-values format and copy that into your email body. TGoddard (7263)
543128 2007-04-22 09:04:00 or what about the old fasion way, save excell file then send it as attachment. tweak'e (69)
543129 2007-04-22 09:48:00 I think you have not got thunderbird setup and registered properly and thus excel cannot start or use its services.
Check out the support website for both excel and thunderbird...
I dont think MS are that anal that they disable external email desktop clients on purpose, but then again I could be wrong.
zcc (50)
543130 2007-04-22 10:09:00 or what about the old fasion way, save excell file then send it as attachment.

I do not use Thunderbird but your idea seems best to me. :)
Sweep (90)
543131 2007-04-22 11:24:00 I don't want to send an attachment because the person receiving it doesn't have MS Excel spaceman8815 (4112)
543132 2007-04-25 06:02:00 Hi

This can be done from Excel using VBA using the ShellExecute API function. However, if Thunderbird has not been installed correctly then this method may not work either.

If you want to try it, then do this:

Open your spreadsheet, open the VBA editor by pressing the Alt+F11 keys together. In the top left hand pane navigate your way to your workbook VBA project (it should appear in bold as VBAProject ('Name'.xls) where 'Name' is the name of your spreadsheet). Under that project you may see Sheet1, Sheet2 etc. down to ThisWorkbook - double click on 'ThisWorkbook' and then copy > paste the following VBA code into the screen on the right hand side of the VBA screen.

Option Explicit

'Used for creating an e-mail
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Sub MySendMail()

Dim sMailTo As String, _
sSubject As String, _
sBody As String, _
stext As String, _
MyCell As Range, _
PrevRow As Long

sMailTo = "someone@domain.com"
sSubject = "Enter subject line here"
sBody = ""
PrevRow = Selection.Row
For Each MyCell In Selection
If MyCell.Row <> PrevRow Then
PrevRow = MyCell.Row
sBody = Left$(sBody, Len(sBody) - 2)
sBody = sBody & "%0D%0A"
End If
sBody = sBody & MyCell.Value & ", "
Next
sBody = Left$(sBody, Len(sBody) - 2)

stext = "mailto:" & sMailTo & "?Subject=" & sSubject & " & Body=" & sBody

If Len(stext) > 2000 Then
MsgBox "That message is too long", vbCritical, "Error"
Else
'Send e-mail
Call ShellExecute(0 & , "open", stext, vbNullString, vbNullString, -1)
End If

End Sub

Change the e-mail address and subject line within the code to suit. Save and close the VBA editor, the go to your spreadsheet, highlight the part of the worksheet you want to e-mail and then click on menu option Tools > Macro > Macros > ThisWorkbook.MySendMail. This routine is not e-mail client specific so provided Thunderbird has been correctly installed then it should work.

Andrew

P.S. this method of sending e-mails has a limit of just over 2k characters so if you are trying to send large chunks of the spreadsheet it may not work. It also tries to send the body of the worksheet as it would a comma delimited file so you won't be getting any pretty formatting etc. - just the contents.
andrew93 (249)
1