Private Sub QuickEmailSend_Click()
Const bq As String = "<blockquote>"
Const bqe As String = "</blockquote>"
'Dim mi As Outlook.MailItem
'Dim ID As String
'Dim user As String
'Dim sentAfter As Date
'FileName = ID
'###
Dim OL As Outlook.Application
Set OL = New Outlook.Application
'Dim user As String
Dim mi As Outlook.MailItem
Dim ID As String
'Dim user As String
Dim sentAfter As Date
filename = ID
user = OL.Session.CurrentUser.Name
'##
user = OL.Session.CurrentUser.Name
Dim Subjectz As String
LetterName = ""
'Me.EmailAccounttoUSe2 = user
' If Me.EmailAccounttoUSe2 = "Gary And EU = True Then Me.EMAILAcc = "x"
'If Me.EmailAccounttoUSe2 = "Gary " And EU = False Then Me.EMAILAcc = "y"
'###
'added 21.09.23
'miniories
'EmailAccounttoUSe
'miniories
If Me.WHOAMI = "gpa" And EU = True Then Me.EMAILAcc = "x"
If Me.WHOAMI = "gpa" And EU = True Then Me.EmailAccounttoUSe = "x"
'Arc
If Me.WHOAMI = "gpa" And EU = False Then Me.EMAILAcc = "y"
If Me.WHOAMI = "gpa" And EU = False Then Me.EmailAccounttoUSe = "y"
'Dim Subjectz As String
Set frm = Forms!websiteimportfrm
With frm
LetterName = ""
If Me.EU = 0 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "AISL2016.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
End If
If Me.EU = -1 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "MIB.htm")
Else:
Signature = ""
End If
'##
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
End If
If Me.accounttype = "1" Then Subjectz = "Our Reference :-" & " " & ![QuickQuoteno]
If Me.accounttype = "2" Then Subjectz = "Our Reference :-" & " " & ![QuickQuoteno] & " - " & "(" & ![QuickInsured] & ")"
If Me.QuickQuoteno < 24876 Then Subjectz = "Our Reference :-" & " " & ![QuickQuoteno]
Set mi = createNewEmail()
' Generate a unique E-mail id
Randomize
ID = Format(Now(), "yyyymmddhhnnss") & "_" & CInt(1000 * Rnd()) + 1
' Save date and time
sentAfter = Now()
' Change mail item properties
With mi
.To = Nz(Me.QuickEmail)
.Subject = Nz(Subjectz)
.HTMLBody = " ." & bqe & bqe & Signature
.Categories = ID
If Me.EU = False Then
.SendUsingAccount = OL.Session.Accounts(1)
End If
If Me.EU = True Then
.SendUsingAccount = OL.Session.Accounts(2)
End If
End With
' Wait until mailitem window has been closed
While MailItemIsOpen(ID)
DoEvents
Wend
' Try to find item in Sent Items
Set mi = FindSentItem(ID, sentAfter)
Sentstamp = mi.SentOn
' E-mail has been sent
If Not (mi Is Nothing) Then
Dim filepathz As String
Dim filenamez As String
Dim Subjectx As String
Subjectx = mi.Subject
' date time stamp on email
filenamepart1 = Format(Sentstamp, "yyyy mm dd-hhnnss")
filenamepart2 = "- " & Subjectx
filenamepart2 = CleanString(mi.Subject)
filename = filenamepart1 & " " & filenamepart2
user = OL.Session.CurrentUser.Name
'##
user = OL.Session.CurrentUser.Name
Dim Subjectz As String
LetterName = ""
'Me.EmailAccounttoUSe2 = user
' If Me.EmailAccounttoUSe2 = "Gary And EU = True Then Me.EMAILAcc = "x"
'If Me.EmailAccounttoUSe2 = "Gary " And EU = False Then Me.EMAILAcc = "y"
'###
'added 21.09.23
'miniories
'EmailAccounttoUSe
'miniories
If Me.WHOAMI = "gpa" And EU = True Then Me.EMAILAcc = "x"
If Me.WHOAMI = "gpa" And EU = True Then Me.EmailAccounttoUSe = "x"
'Arc
If Me.WHOAMI = "gpa" And EU = False Then Me.EMAILAcc = "y"
If Me.WHOAMI = "gpa" And EU = False Then Me.EmailAccounttoUSe = "y"
'Dim Subjectz As String
Set frm = Forms!websiteimportfrm
With frm
LetterName = ""
If Me.EU = 0 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "AISL2016.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
End If
If Me.EU = -1 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "MIB.htm")
Else:
Signature = ""
End If
If Me.QuickQuoteno < 24876 Then Subjectz = "Our Reference :-" & " " & ![QuickQuoteno]
Set mi = createNewEmail()
' Generate a unique E-mail id
Randomize
ID = Format(Now(), "yyyymmddhhnnss") & "_" & CInt(1000 * Rnd()) + 1
' Save date and time
sentAfter = Now()
' Change mail item properties
With mi
.To = Nz(Me.QuickEmail)
.Subject = Nz(Subjectz)
.HTMLBody = " ." & bqe & bqe & Signature
.Categories = ID
If Me.EU = False Then
.SendUsingAccount = OL.Session.Accounts(1)
End If
If Me.EU = True Then
.SendUsingAccount = OL.Session.Accounts(2)
End If
End With
' Wait until mailitem window has been closed
While MailItemIsOpen(ID)
DoEvents
Wend
' Try to find item in Sent Items
Set mi = FindSentItem(ID, sentAfter)
Sentstamp = mi.SentOn
' E-mail has been sent
If Not (mi Is Nothing) Then
Dim filepathz As String
Dim filenamez As String
Dim Subjectx As String
Subjectx = mi.Subject
' date time stamp on email
filenamepart1 = Format(Sentstamp, "yyyy mm dd-hhnnss")
filenamepart2 = "- " & Subjectx
filenamepart2 = CleanString(mi.Subject)
filename = filenamepart1 & " " & filenamepart2
' edit to this form
filepathz = Me.openfolderxx & filenamepart1 & " " & filenamepart2
What is the issue with formatting the code? No one want to read that garbage. You are wasting peoples time.
Properly format it if you want people to look at it.
Const bq As String = "<blockquote>"
Const bqe As String = "</blockquote>"
'Dim mi As Outlook.MailItem
'Dim ID As String
'Dim user As String
'Dim sentAfter As Date
'FileName = ID
'###
Dim OL As Outlook.Application
Set OL = New Outlook.Application
'Dim user As String
Dim mi As Outlook.MailItem
Dim ID As String
'Dim user As String
Dim sentAfter As Date
filename = ID
user = OL.Session.CurrentUser.Name
'##
user = OL.Session.CurrentUser.Name
Dim Subjectz As String
LetterName = ""
'Me.EmailAccounttoUSe2 = user
' If Me.EmailAccounttoUSe2 = "Gary And EU = True Then Me.EMAILAcc = "x"
'If Me.EmailAccounttoUSe2 = "Gary " And EU = False Then Me.EMAILAcc = "y"
'###
'added 21.09.23
'miniories
'EmailAccounttoUSe
'miniories
If Me.WHOAMI = "gpa" And EU = True Then Me.EMAILAcc = "x"
If Me.WHOAMI = "gpa" And EU = True Then Me.EmailAccounttoUSe = "x"
'Arc
If Me.WHOAMI = "gpa" And EU = False Then Me.EMAILAcc = "y"
If Me.WHOAMI = "gpa" And EU = False Then Me.EmailAccounttoUSe = "y"
'Dim Subjectz As String
Set frm = Forms!websiteimportfrm
With frm
LetterName = ""
If Me.EU = 0 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "AISL2016.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
End If
If Me.EU = -1 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "MIB.htm")
Else:
Signature = ""
End If
If Me.QuickQuoteno < 24876 Then Subjectz = "Our Reference :-" & " " & ![QuickQuoteno]
Set mi = createNewEmail()
' Generate a unique E-mail id
Randomize
ID = Format(Now(), "yyyymmddhhnnss") & "_" & CInt(1000 * Rnd()) + 1
' Save date and time
sentAfter = Now()
' Change mail item properties
With mi
.To = Nz(Me.QuickEmail)
.Subject = Nz(Subjectz)
.HTMLBody = " ." & bqe & bqe & Signature
.Categories = ID
If Me.EU = False Then
.SendUsingAccount = OL.Session.Accounts(1)
End If
If Me.EU = True Then
.SendUsingAccount = OL.Session.Accounts(2)
End If
End With
' Wait until mailitem window has been closed
While MailItemIsOpen(ID)
DoEvents
Wend
' Try to find item in Sent Items
Set mi = FindSentItem(ID, sentAfter)
Sentstamp = mi.SentOn
' E-mail has been sent
If Not (mi Is Nothing) Then
Dim filepathz As String
Dim filenamez As String
Dim Subjectx As String
Subjectx = mi.Subject
' date time stamp on email
filenamepart1 = Format(Sentstamp, "yyyy mm dd-hhnnss")
filenamepart2 = "- " & Subjectx
filenamepart2 = CleanString(mi.Subject)
filename = filenamepart1 & " " & filenamepart2
' edit to this form
filepathz = Me.openfolderxx & filenamepart1 & " " & filenamepart2
"New" Outlook does not respond to VBA because it has abandoned the Component Object Model that VBA uses. I have not seen many reports of people automating New Outlook via any of the normal automation methods. (Admittedly I could have missed seeing them... if any existed.)
"New" Outlook does not respond to VBA because it has abandoned the Component Object Model that VBA uses. I have not seen many reports of people automating New Outlook via any of the normal automation methods. (Admittedly I could have missed seeing them... if any existed.)
Const bq As String = "<blockquote>"
Const bqe As String = "</blockquote>"
'Dim mi As Outlook.MailItem
'Dim ID As String
'Dim user As String
'Dim sentAfter As Date
'FileName = ID
'###
Dim OL As Outlook.Application
Set OL = New Outlook.Application
'Dim user As String
Dim mi As Outlook.MailItem
Dim ID As String
'Dim user As String
Dim sentAfter As Date
filename = ID
user = OL.Session.CurrentUser.Name
'##
user = OL.Session.CurrentUser.Name
Dim Subjectz As String
LetterName = ""
'Me.EmailAccounttoUSe2 = user
' If Me.EmailAccounttoUSe2 = "Gary And EU = True Then Me.EMAILAcc = "x"
'If Me.EmailAccounttoUSe2 = "Gary " And EU = False Then Me.EMAILAcc = "y"
'###
'added 21.09.23
'miniories
'EmailAccounttoUSe
'miniories
If Me.WHOAMI = "gpa" And EU = True Then Me.EMAILAcc = "x"
If Me.WHOAMI = "gpa" And EU = True Then Me.EmailAccounttoUSe = "x"
'Arc
If Me.WHOAMI = "gpa" And EU = False Then Me.EMAILAcc = "y"
If Me.WHOAMI = "gpa" And EU = False Then Me.EmailAccounttoUSe = "y"
'Dim Subjectz As String
Set frm = Forms!websiteimportfrm
With frm
LetterName = ""
If Me.EU = 0 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "AISL2016.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
End If
If Me.EU = -1 Then
Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "MIB.htm")
Else:
Signature = ""
End If
If Me.QuickQuoteno < 24876 Then Subjectz = "Our Reference :-" & " " & ![QuickQuoteno]
Set mi = createNewEmail()
' Generate a unique E-mail id
Randomize
ID = Format(Now(), "yyyymmddhhnnss") & "_" & CInt(1000 * Rnd()) + 1
' Save date and time
sentAfter = Now()
' Change mail item properties
With mi
.To = Nz(Me.QuickEmail)
.Subject = Nz(Subjectz)
.HTMLBody = " ." & bqe & bqe & Signature
.Categories = ID
If Me.EU = False Then
.SendUsingAccount = OL.Session.Accounts(1)
End If
If Me.EU = True Then
.SendUsingAccount = OL.Session.Accounts(2)
End If
End With
' Wait until mailitem window has been closed
While MailItemIsOpen(ID)
DoEvents
Wend
' Try to find item in Sent Items
Set mi = FindSentItem(ID, sentAfter)
Sentstamp = mi.SentOn
' E-mail has been sent
If Not (mi Is Nothing) Then
Dim filepathz As String
Dim filenamez As String
Dim Subjectx As String
Subjectx = mi.Subject
' date time stamp on email
filenamepart1 = Format(Sentstamp, "yyyy mm dd-hhnnss")
filenamepart2 = "- " & Subjectx
filenamepart2 = CleanString(mi.Subject)
filename = filenamepart1 & " " & filenamepart2
' edit to this form
filepathz = Me.openfolderxx & filenamepart1 & " " & filenamepart2