Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Different Email Address via VBA

Status
Not open for further replies.

hpicken

Technical User
Apr 12, 2001
142
AU
I have the following code (compliments from the guys on this forum)

Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Dim objOutlook As Outlook.Application
Dim Myitem

Dim strTextLine As String
Dim strTemplate As String

strTemplate = "It's that time again." & Chr(13) & Chr(10) _
& "Can you please supply your info for the following equipment." & Chr(13) & Chr(10)

Set rst = db.OpenRecordset("Select * from eqryNewReadingsMail Where Month(duedate)=5 AND Year(duedate)=2002")
Set objOutlook = CreateObject("Outlook.Application")

'Cycle through the table, sending it to each person on the list
Do While Not rst.EOF
Set Myitem = objOutlook.CreateItem(olMailItem)
Myitem.Subject = "Equipment info time."
Myitem.SentOnBehalfOfName = "Readings"
Myitem.Body = vbCrLf & strTemplate
Myitem.To = CStr(rst!ContEmail)
Myitem.Send
If Not rst.EOF Then
rst.MoveNext
End If
Loop
Set objOutlook = Nothing
rst.Close
Set rst = Nothing
Set db = Nothing

Exit_btnContinue_Click:
Exit Sub

Err_btnContinue_Click:
MsgBox Err.Description
Resume Exit_btnContinue_Click

End Sub


Now this works OK, but it sends the mail using my default Outlook Email address. What I would like to do is either provide a mail link in the mail (for replying to) or have the email sent by a different address so that when they reply it goes to the email address I want it to not the my default Outlook email address.

Any ideas would be much appreciated.

TIA

Howard
 
Ratman's special of the day !

How's this embeded in the body......

strTemplate = "It's that time again." & Chr(13) & Chr(10) _
& "Can you please supply your info for the following equipment." & Chr(13) & Chr(10) & reply to youremailaddy@something.com
 
Myitem.ReplyRecipientNames = "persontoreplyto@yourcompany.com"
 
I tried both ways.

The address in the body doesn't come up as email link just text.

The second way still shows the mail as coming from but replies to the new address. So I'll use that way.

Thanks all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top