Sam Summers
Registered User.
- Local time
- Today, 05:29
- Joined
- Sep 17, 2001
- Messages
- 939
I had all this working perfectly from outlook before we swapped over to outlook 365.
So from the form frmPO i have this code:
But the above code is producing the error - 8004020d I dont want to use the From field as that is not necessary.
I was using this Function before:
But this now does no longer work.
Can anyone see any glaring issues?
Many thanks as always.
Sam
So from the form frmPO i have this code:
Code:
Private Sub OrderValue_AfterUpdate()
Dim mailTo As String
Dim Body As String
Dim Subject As String
' Dim attch As String
Dim lngWhite As Long
If Nz(Me.OtherField, "") = "" Or Nz(Me.SiteID.Value, "") = "" Or Nz(Me.OrderedForID.Value, "") = "" Then
MsgBox "You must enter a Description, Location and who ordered for", _
vbOKOnly Or vbInformation, "Information required"
Exit Sub
End If
If Me.OrderValue > 500 Then
MsgBox "Your order is above the threshold and has been sent for approval ", _
vbOKOnly Or vbInformation, "Approval required"
Forms!frmPO!SupplierSubform.Form!Body.SetFocus
Forms!frmPO!SupplierSubform.Form!Body.Text = ""
Me.ApprovalCode.SetFocus
Dim mail As CDO.Message
Dim config As CDO.Configuration
Set mail = CreateObject("CDO.Message")
Set config = CreateObject("CDO.Configuration")
config.Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
config.Fields(cdoSMTPServer).Value = "mail.summer-isles.com"
config.Fields(cdoSMTPServerPort).Value = 25
config.Fields.Update
Set mail.Configuration = config
With mail
.To = "sam.s@summer-isles.com"
' .From = ""
.Subject = "Request for approval. " & " Approval Code - " & Me.ApprovalCode.Text
.TextBody = "Please can you approve this order of " & Me.OtherField & " for " & Me.SiteID.Column(1) & " to the value of £" & Me.OrderValue
.Send
End With
Set config = Nothing
Set mail = Nothing
' mailTo = "sam.s@summer-isles.com"
' Subject = "Request for approval. " & " Approval Code - " & Me.ApprovalCode.Text
' Body = "Please can you approve this order of " & Me.OtherField & " for " & Me.SiteID.Column(1) & " to the value of £" & Me.OrderValue
'
' Call SendEmailWithOutlook2(mailTo, Subject, Body)
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
Else
' Me.PODate.Enabled = True
' Me.OrderedBy.Enabled = True
Me.Approved.Visible = True
Me.Label49.Visible = True
Me.Approved.Value = True
Me.PONumber.Visible = True
lngWhite = RGB(255, 255, 255)
Me!PONumber.ForeColor = lngWhite
' Me.PODate.SetFocus
End If
End Sub
But the above code is producing the error - 8004020d I dont want to use the From field as that is not necessary.
I was using this Function before:
Code:
Public Function SendEmailWithOutlook2()
Dim strTo As String
Dim strMessage As String
Dim Subject As String
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strBody As String
Dim strEmail As String
Dim strSubject As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Set OutMail = OutApp.CreateItem(olMailItem)
strEmail = strTo
strBody = strMessage
strTo = "sam.s@summer-isles.com"
strSubject = "Request for approval. " & " Approval Code - " & Me.ApprovalCode.Text
strMessage = "Please can you approve this order of " & Me.OtherField & " for " & Me.SiteID.Column(1) & " to the value of £" & Me.OrderValue
With OutMail
.To = strTo
' .Attachments.Add strAttachment
' .CC = "djh902@gmail.com"
.Subject = strSubject
.Body = strBody
.Send ' Send the message immediately
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Function
But this now does no longer work.
Can anyone see any glaring issues?
Many thanks as always.
Sam