|
-
Jan 18th, 2011, 11:57 AM
#1
Thread Starter
Hyperactive Member
Is it possible to send messages from Excel?
Is it possible to send an email message from Excel to someone when the 'To' person's email address is known but there is actually no 'From' person or address? Here's the scenario. Excel is opened as a scheduled task; i.e., one created by the system administrator. When started, a workbook is opened and a macro is automatically run. When the macro is finished, I want it to send an email notification to certain people. I have the IP address of the Exchange Server. Thanks.
-
Jan 18th, 2011, 12:01 PM
#2
Re: Is it possible to send messages from Excel?
The email account of whoever is logged into the machine at the time will be the default "From" addressee.
For situations such as this a generic windows login id, with an associated mailbox, is generally used.
-
Jan 18th, 2011, 12:37 PM
#3
Thread Starter
Hyperactive Member
Re: Is it possible to send messages from Excel?
Thanks for your quick response.
So, if the scheduled task was created by the system administrator, would his email address be used as the 'From' address? And if the DOS batch job (.bat) was started by a user, then would their email address be used as 'From' address?
If either is the case, how would the generic log in be implemented?
-
Jan 18th, 2011, 12:42 PM
#4
Re: Is it possible to send messages from Excel?
It doesn't matter if the job was generated by Santa Claus...the email "From" addressee with be whoever is logged into the computer at the time. That is where the generic id comes in.
-
Jan 18th, 2011, 12:47 PM
#5
Thread Starter
Hyperactive Member
Re: Is it possible to send messages from Excel?
I'm sorry, but I still don't understand and I appreciate your patience. I can understand if someone starts the job. But if the job is started by Windows as a scheduled task, then where does the id come from if there are many people logged into the server?
Thanks.
-
Jan 18th, 2011, 12:50 PM
#6
Re: Is it possible to send messages from Excel?
There is only one person logged into Windows itself. You can't have more than one person logged into the operating system of the machine at any one time.
-
Jan 18th, 2011, 12:58 PM
#7
Thread Starter
Hyperactive Member
Re: Is it possible to send messages from Excel?
The sceduled task is set up on a Terminal Server and no one may be logged on when it starts.
-
Jan 18th, 2011, 03:51 PM
#8
Re: Is it possible to send messages from Excel?
why not test it and see? send email to self and find who it is from
how are you going to send the email?
are you sending a workbook using excels built in .sendmail
or are you going to automate outlook, use cdo.message, or someother method
if you use outlook the sender will be the current outlook profile
if you use cdo you can set the sender, but the server may prevent mail from being sent by anyone who does not have an account on that servr
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 18th, 2011, 05:05 PM
#9
Thread Starter
Hyperactive Member
Re: Is it possible to send messages from Excel?
Thanks again for trying to help. I'm using CDO. If I use Gmail as the SMTP server, I can send an email via the batch script on the server from a Gmail email address (one that I set up) to any email address with no problem. But when a user starts the same DOS script that starts the Excel job, they get a 80040217 'transport failed to connect to server' error. In any case, the system administrator would rather not use an external SMTP service like Gmail. If I use the IP address of the Exchange server, and plug in a valid sender's address (like [email protected]), it still won't work. Either get connect failures, or relay failures, or other errors.
-
Jan 18th, 2011, 08:40 PM
#10
Thread Starter
Hyperactive Member
Re: Is it possible to send messages from Excel?
This is CDO code that I'm working with. I've tried different options with no luck:
Code:
sender = "[email protected]"
to_addr = "[email protected]"
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") _
= True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") _
= 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _
= 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= "999.999.999.99"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
= 25
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") _
= sender
.Update
End With
Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = to_addr
.From = sender
.Subject = "Test"
.TextBody = "Test"
.Send
End With
Results in 'Transport failed to connect to server' error.
-
Jan 19th, 2011, 02:40 AM
#11
Re: Is it possible to send messages from Excel?
if you change from the default sender the message may fail to be sent
many smtp servers, including gmail, prevent email address spoofing, for reasons of spam prevention, last time i tested, gmail used the logged in user id as sender regardless of what sender was set in the code
does it really matter who is the displayed sender?
put something in the subject line to indicate who the email comes from
if i change none of the configuration settings at all an email will be sent, but you can not guarantee that on any one elses computer, as they may have no default settings, this is where sending via gmail has advantages, as you can use a know configuration, but the sender must be the gmail user account name
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 19th, 2011, 12:56 PM
#12
Thread Starter
Hyperactive Member
Re: Is it possible to send messages from Excel?
Thanks again. Gmail would have been a solution, I think, but SA doesn't want to use outside SMTP service. I've asked a user on the system to execute the script and they also get errors, so I don't know where to go next. Like I said, I have the IP of the exchange server, and I have valid email addresses of users who would be receiving email. But no amount of including or excluding or changing the parameters above have gotten me any success.
-
Jan 19th, 2011, 03:23 PM
#13
Re: Is it possible to send messages from Excel?
sorry i can not test with your server, to know what limitations (security or other) it may have
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|