Email in Excel

Parkre

Senior member
Jul 31, 2005
616
0
0
I've got new code that works and sends without incident or errors other than...

"An outside program is trying to send an email on behalf, would you like it to send?"






I found this code, I am not a programmer, I'm an M.E., so I do have basics.

<edited out code for code that's working>


I do use Microsoft Outlook, a secure server, & macafee virus scanner. This code should work. I had other errors along the way, but got them worked out. I thought maybe this is being block my macafee, but i completely disabled and exited macafee.

Does anyone else have any ideas??



 

Parkre

Senior member
Jul 31, 2005
616
0
0
here's the new code


Sub Button9_Click()


' Select the range of cells on the active worksheet.
ActiveSheet.Range("H13:I20").Select

' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True


With ActiveSheet.MailEnvelope
.Introduction = "This is the Job Brief"
.Item.To = "jhoskins@gggggggg.com"
.Item.Subject = "Job Debrief"
.Item.Send
End With

End Sub

But I would like the code to retrieve a cell value and put it into the

.Item.Subject = "Cell Value"

this is code pulls the cell value and saves the Workbook as the Cell Value

ActiveWorkbook.SaveAs Filename:= _
"D:\WSD\" & Worksheets("Data").Range("SON").Value & ".script", FileFormat:= _
xlText, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False

Could I change this around to input it into the Subject??
Anyone?
 

PowerEngineer

Diamond Member
Oct 22, 2001
3,615
799
136

Funny you should bring this up right now. We've just switched over to Outlook (from Groupwise) at work, and so I just did some work on some Excel macros that send e-mails.

I believe that that warning pop-up box you're seeing is being generated by Outlook (for the reason it states), not really by Excel or your macro. So far I haven't figured out how (or if) I can disable it. In the meantime, just click "yes" and your e-mail will be sent.
 

Parkre

Senior member
Jul 31, 2005
616
0
0
Yep, I don't have a problem waiting 5 seconds for it to email. It's still quicker than opeing an new email, copy and paste, typing in the email address...etc.

But I was wondering if I could change the "Job Debrief" to "Job Debrief of (company)"

Retrieving one of the cell values for the company. I know it's possible because I got it to save the spreadsheet as one of the cell values.
 

KLin

Lifer
Feb 29, 2000
30,951
1,079
126
.Item.Subject = "Job Debrief of " & ActiveSheet.Cells(1, "A")

That's if the company value is always stored in the same cell.
 

Parkre

Senior member
Jul 31, 2005
616
0
0
It is!

That's exactly what I needed.



Can I attach a file from my desktop folder? It's an .rtf file.

Thanks a bunch.
 

Parkre

Senior member
Jul 31, 2005
616
0
0
This is what I could find on attaching files.

.Attachments.Add = "C:\Documents and Settings\Jhoskins\Desktop\WRS-RTF" & Worksheets("Data").Range("SON").Value & ".rtf"


It is an .rtf file.
 

KLin

Lifer
Feb 29, 2000
30,951
1,079
126
If you want to make it user specific you can do the following

.Attachments.Add = Environ("USERPROFILE") & "\Desktop\WRS-RTF" & Worksheets("Data").Range("SON").Value & ".rtf"

 

Parkre

Senior member
Jul 31, 2005
616
0
0
I got a "Object doesn't support this property or method"

It won't add the attachment. I have found that there is different code for MS Outlook (what I have) and MS Outlook Express which willl screw things up.
 

Parkre

Senior member
Jul 31, 2005
616
0
0
Neither work,

.Attachments.Add = Environ("USERPROFILE") & "\Desktop\WRS-RTF" & Worksheets("Data").Range("SON").Value & ".rtf"

or

.Attachments.Add = "C:\Documents and Settings\Jhoskins\Desktop\WRS-RTF" & Worksheets("Data").Range("SON").Value & ".rtf"

Am I using the wrong nomenclature? or is it out of order??