Anybody here good with VB code?
One of my customers is trying to send out some mailshot using MS Access with intergrates with Outlook to send the email.
They don't want the email to be from
internalemployeename@company.co.uk but to use
enquiries@company.co.uk.
The code I have been given is like this:
Quote:
Sub SendMessages(Optional AttachmentPath)
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim TheAddress As String
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("tblMailingList")
MyRS.MoveFirst
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
Do Until MyRS.EOF
' Create the e-mail message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
TheAddress = MyRS![strEmailAddress]
With objOutlookMsg
' Add the To recipients to the e-mail message.
Set objOutlookRecip = .Recipients.Add(TheAddress)
objOutlookRecip.Type = olTo
' Add the Cc recipients to the e-mail message.
'If (IsNull(Forms!frmMail!CCAddress)) Then
'Else
' Set objOutlookRecip =
.Recipients.Add(Forms!frmMail!CCAddress)
' objOutlookRecip.Type = olCC
'End If
' Set the Subject, the Body, and the Importance of the e-mail message.
.Subject = Forms!frmMail!strSubject
.Body = Forms!frmMail!strText
.Importance = olImportanceHigh 'High importance
'Add the attachment to the e-mail message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve the name of each Recipient.
'For Each objOutlookRecip In .Recipients
' objOutlookRecip.Resolve
' If Not objOutlookRecip.Resolve Then
' objOutlookMsg.Display
' End If
'Next
.Send
End With
MyRS.MoveNext
|
My question is - is there a string of code which they can add /change so the email forced out with the senders address as
enquiries@company.co.uk?
Thanks for the advice!