Specify SenderEmailAccount in VBA

S

Song Su

Access 2007

I want to specify SenderEmailAddress. When I add .SenderEmailAddress = "someone @ yahoo.com", it gives me "Can't assign read only property" error message when compiling. Here is my code:

Private Sub cmdEmail_Click()
If IsNull(Me.Email) Then
MsgBox "No email address.", , conAppName
Else
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim ctlBody As String

Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
ctlBody = "Dear " & IIf([Sex] = "M", "Mr. ", "Ms. ") & StrConv([FIRSTName], 3) & " " & IIf(IsNull([M]), "", [M] & ". ") & StrConv([LASTName], 3) & ","
With objMail
' I insert code here but cannot compile
.To = Me.Email
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>" & ctlBody & "</p></BODY></HTML>"
.Display
End With

Set objMail = Nothing
Set olApp = Nothing
End If
End Sub
 
B

bhicks11 via AccessMonster.com

Hi Song Su:

Yes, that property cannot be set - it is read only. The sender email is the
actual sender. If you could set it, you could be impersonating someone.

However, see if this link helps:

http://support.microsoft.com/Kb/Q232309

Bonnie
http://www.dataplus-svc.com

Song said:
Access 2007

I want to specify SenderEmailAddress. When I add .SenderEmailAddress = "someone @ yahoo.com", it gives me "Can't assign read only property" error message when compiling. Here is my code:

Private Sub cmdEmail_Click()
If IsNull(Me.Email) Then
MsgBox "No email address.", , conAppName
Else
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim ctlBody As String

Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
ctlBody = "Dear " & IIf([Sex] = "M", "Mr. ", "Ms. ") & StrConv([FIRSTName], 3) & " " & IIf(IsNull([M]), "", [M] & ". ") & StrConv([LASTName], 3) & ","
With objMail
' I insert code here but cannot compile
.To = Me.Email
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>" & ctlBody & "</p></BODY></HTML>"
.Display
End With

Set objMail = Nothing
Set olApp = Nothing
End If
End Sub
 
S

Song Su

But I already setup my outlook with multiple email accounts and they all
tested ok. How to pick the FROM account that is not default email account?
Manually, Outlook allows me to pick FROM. How to do it programmatically?

My actual situation is: The office hire several student workers to work on
the database application. Each student worker log into his/her own network
account. However, we want email sent from generic office email account
(elac_iso), not student worker's own outlook mail account. This way, we can
centralize out going and incomming emails in elac_iso account.

bhicks11 via AccessMonster.com said:
Hi Song Su:

Yes, that property cannot be set - it is read only. The sender email is
the
actual sender. If you could set it, you could be impersonating someone.

However, see if this link helps:

http://support.microsoft.com/Kb/Q232309

Bonnie
http://www.dataplus-svc.com

Song said:
Access 2007

I want to specify SenderEmailAddress. When I add .SenderEmailAddress =
"someone @ yahoo.com", it gives me "Can't assign read only property" error
message when compiling. Here is my code:

Private Sub cmdEmail_Click()
If IsNull(Me.Email) Then
MsgBox "No email address.", , conAppName
Else
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim ctlBody As String

Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
ctlBody = "Dear " & IIf([Sex] = "M", "Mr. ", "Ms. ") &
StrConv([FIRSTName], 3) & " " & IIf(IsNull([M]), "", [M] & ". ") &
StrConv([LASTName], 3) & ","
With objMail
' I insert code here but cannot compile
.To = Me.Email
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>" & ctlBody & "</p></BODY></HTML>"
.Display
End With

Set objMail = Nothing
Set olApp = Nothing
End If
End Sub
 
B

bhicks11 via AccessMonster.com

Ah - I see. Here's a link to a possible solution:

http://dynamicsuser.net/forums/p/7714/89550.aspx

Bonnie
http://www.dataplus-svc.com

Song said:
But I already setup my outlook with multiple email accounts and they all
tested ok. How to pick the FROM account that is not default email account?
Manually, Outlook allows me to pick FROM. How to do it programmatically?

My actual situation is: The office hire several student workers to work on
the database application. Each student worker log into his/her own network
account. However, we want email sent from generic office email account
(elac_iso), not student worker's own outlook mail account. This way, we can
centralize out going and incomming emails in elac_iso account.
Hi Song Su:
[quoted text clipped - 40 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top