Question on SendMail object

Question on SendMail object

am 21.04.2008 23:39:39 von SteveB

Re: Access 2003

I have a line of code in my app that sends an email after these strings
are populated: gblSendTo, gblEMailSubject, and gblEMailBody.

DoCmd.SendObject , "", "", gblSendTo, "", "", gblEMailSubject,
gblEMailBody, False, ""

Currently, when the email is sent internally in our company, the "From:"
in the email is my own personal work address.

I did not see in the syntax (unless I missed it) where the "From:" can
be set in the "SendMail" object in Access.

There is a department address we can use as the "From".

How do I change my code so that when the users see the email sent by the
app, it shows up as
"From: and not from "MyName@company.com"?

Thanks.

(I don't know if this matters or not, but we useMicrosoft Exchange
Server for internal email.)



*** Sent via Developersdex http://www.developersdex.com ***

Re: Question on SendMail object

am 22.04.2008 00:34:43 von Lars Brownie

I don't think this can be done with SendObject. However, you cán do it with
Outlook automation, more specifically using the .SendOnBehalfOf property,
see:

http://www.talkaboutdatabases.com/group/comp.databases.ms-ac cess/messages/887159.html

Lars

"RLN" schreef in bericht
news:1208813425_120@news.newsfeeds.com...
> Re: Access 2003
>
> I have a line of code in my app that sends an email after these strings
> are populated: gblSendTo, gblEMailSubject, and gblEMailBody.
>
> DoCmd.SendObject , "", "", gblSendTo, "", "", gblEMailSubject,
> gblEMailBody, False, ""
>
> Currently, when the email is sent internally in our company, the "From:"
> in the email is my own personal work address.
>
> I did not see in the syntax (unless I missed it) where the "From:" can
> be set in the "SendMail" object in Access.
>
> There is a department address we can use as the "From".
>
> How do I change my code so that when the users see the email sent by the
> app, it shows up as
> "From: and not from "MyName@company.com"?
>
> Thanks.
>
> (I don't know if this matters or not, but we useMicrosoft Exchange
> Server for internal email.)
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***

Re: Question on SendMail object

am 24.04.2008 18:13:43 von RLN

Thank you for this tip here. I am going to try the code from the link
you provided.

I am somewhat new to using the Outlook Object model inside of an Access
app. If you have any tips or good coding practices for using this this
specific object model efficiently, I would welcome your suggestions.

I read in another thread where "SendOnBehalfOf" has a permission that
has to be granted. Where is this set/modified?

In my Access app, the "From" address must change before the email is
sent, only if the current record in the database came from a source
different than the previous record.


*** Sent via Developersdex http://www.developersdex.com ***

Re: Question on SendMail object

am 24.04.2008 18:28:44 von Lyle Fairfield

RLN wrote in news:1209053070_367@news.newsfeeds.com:

> I am somewhat new to using the Outlook Object model inside of an Access
> app. If you have any tips or good coding practices for using this this
> specific object model efficiently, I would welcome your suggestions.

I suggest that you use CDO.

Re: Question on SendMail object

am 24.04.2008 20:18:43 von Lars Brownie

"RLN" schreef in bericht
news:1209053070_367@news.newsfeeds.com...
>
> Thank you for this tip here. I am going to try the code from the link
> you provided.
>
> I am somewhat new to using the Outlook Object model inside of an Access
> app. If you have any tips or good coding practices for using this this
> specific object model efficiently, I would welcome your suggestions.

To use it you must make sure that the Outlook reference in Access is
checked.

> I read in another thread where "SendOnBehalfOf" has a permission that
> has to be granted. Where is this set/modified?

In the exchange server the users should have send-as rights on the
department mailbox.

> In my Access app, the "From" address must change before the email is
> sent, only if the current record in the database came from a source
> different than the previous record.

In your code you can set the SendOnBehalfOf property or not set it at all on
the basis of the criteria you mention.

Lars

Re: Question on SendMail object

am 24.04.2008 20:59:47 von Tony Toews

"Lars Brownie" wrote:

>To use it you must make sure that the Outlook reference in Access is
>checked.

However, given that folks may have different versions of Outlook installed or maybe
not even have it installed, I'd suggest switching your code to late binding once it's
working.

Late binding means you can safely remove the reference and only have an error when
the app executes lines of code in question. Rather than erroring out while starting
up the app and not allowing the users in the app at all. Or when hitting a mid, left
or trim function call.

For more information including additional text and some detailed links see the "Late
Binding in Microsoft Access" page at http://www.granite.ab.ca/access/latebinding.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

Re: Question on SendMail object

am 24.04.2008 21:07:53 von Lars Brownie

Thanks for the tip. Didn't know about that.

"Tony Toews [MVP]" schreef in bericht
news:q2m11455fcdqeqqloi7lnqiturhc633924@4ax.com...
> "Lars Brownie" wrote:
>
>>To use it you must make sure that the Outlook reference in Access is
>>checked.
>
> However, given that folks may have different versions of Outlook installed
> or maybe
> not even have it installed, I'd suggest switching your code to late
> binding once it's
> working.
>
> Late binding means you can safely remove the reference and only have an
> error when
> the app executes lines of code in question. Rather than erroring out
> while starting
> up the app and not allowing the users in the app at all. Or when hitting
> a mid, left
> or trim function call.
>
> For more information including additional text and some detailed links see
> the "Late
> Binding in Microsoft Access" page at
> http://www.granite.ab.ca/access/latebinding.htm
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Please respond only in the newsgroups so that others can
> read the entire thread of messages.
> Microsoft Access Links, Hints, Tips & Accounting Systems at
> http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/