mgmhicks
asked on
Sending email using cdo_message
I have this piece of code that is supposed to send email without outlook being opened. Could someone clean this up so it works, I was originally trying with the Outlook application object, but that only sent email if outlook was open, I need it to be sent even if outlooks is not open. So I am trying cdo but when it hits line
With cdo_message
Set .Configuration = cdo_config
End With
I receive object required.
thanks in advance
(Edit: Redacted - Modulus_Twelve)
With cdo_message
Set .Configuration = cdo_config
End With
I receive object required.
thanks in advance
Dim myString As String
myString = "Item: " & Cells(myRow, 2) & vbCrLf & vbCrLf
myString = myString & "Detail Description: " & Cells(myRow, 3) & vbCrLf & vbCrLf
myString = myString & "Detail Comments: " & Cells(myRow, 4) & vbCrLf & vbCrLf
myString = myString & "Resolution: " & Cells(myRow, 5) & vbCrLf & vbCrLf
myString = myString & "Proposal due Date: " & Cells(myRow, 6) & vbCrLf & vbCrLf
myString = myString & "Who is obtaining?: " & Cells(myRow, 7) & vbCrLf & vbCrLf
myString = myString & "Target Date: " & Cells(myRow, 8) & vbCrLf & vbCrLf
myString = myString & "Date Proposal Received: " & Cells(myRow, 9) & vbCrLf & vbCrLf
myString = myString & "Date of SignOff: " & Cells(myRow, 10) & vbCrLf & vbCrLf
myString = myString & "Date Work Completed: " & Cells(myRow, 11) & vbCrLf & vbCrLf
myString = myString & "Follow Up Date: " & Cells(myRow, 12) & vbCrLf & vbCrLf
myString = myString & "Extra Notes: " & Cells(myRow, 13) & vbCrLf & vbCrLf
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error GoTo Problem
' Change the mail address and subject in the macro before you run it.
'' With OutMail
'' .To = "dprogelhof@theapartmentgallery.com; fsturgill@theapartmentgallery.com"
'' .CC = "shicks@theapartmentgallery.com"
'' .BCC = ""
'' .Subject = "There is a issue with inspection: " & Cells(6, 3)
'' .Body = myString
'' .Attachments.Add ActiveWorkbook.FullName
'' You can add other files by uncommenting the following line.
'' .Attachments.Add ("C:\test.txt")
'' In place of the following statement, you can use ".Display" to
'' display the mail.
'' .Send
'' End With
Set CD0_Mail = CreateObject("CDO.message")
Set cdo_config = CreateObject("CDO.Configuration")
cdo_config.Load = -1
Set smtp_config = cdo_config.Fields
With smtp_config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "APTEMAILSERVER2.mail2.apartmentgallery.net"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item(cdoSMTPAuthenticate) = 1
.Item(cdoSendUserName) = "*****"
.Item(cdoSendPassword) = "*****"
.Update
End With
With cdo_message
Set .Configuration = cdo_config
End With
With cdo_message
.To = "dprogelhof@theapartmentgallery.com; fsturgill@theapartmentgallery.com"
.CC = "shicks@theapartmentgallery.com"
.BCC = ""
.Subject = "There is a issue with inspection: " & Cells(6, 3)
.Body = myString
'.Attachments.Add ActiveWorkbook.FullName
' You can add other files by uncommenting the following line.
'.Attachments.Add ("C:\test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Exit Function
Problem:
MsgBox Err.Description
Exit Function
(Edit: Redacted - Modulus_Twelve)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this
OM Gang
Dim myString As String
myString = "Item: " & Cells(myRow, 2) & vbCrLf & vbCrLf
myString = myString & "Detail Description: " & Cells(myRow, 3) & vbCrLf & vbCrLf
myString = myString & "Detail Comments: " & Cells(myRow, 4) & vbCrLf & vbCrLf
myString = myString & "Resolution: " & Cells(myRow, 5) & vbCrLf & vbCrLf
myString = myString & "Proposal due Date: " & Cells(myRow, 6) & vbCrLf & vbCrLf
myString = myString & "Who is obtaining?: " & Cells(myRow, 7) & vbCrLf & vbCrLf
myString = myString & "Target Date: " & Cells(myRow, 8) & vbCrLf & vbCrLf
myString = myString & "Date Proposal Received: " & Cells(myRow, 9) & vbCrLf & vbCrLf
myString = myString & "Date of SignOff: " & Cells(myRow, 10) & vbCrLf & vbCrLf
myString = myString & "Date Work Completed: " & Cells(myRow, 11) & vbCrLf & vbCrLf
myString = myString & "Follow Up Date: " & Cells(myRow, 12) & vbCrLf & vbCrLf
myString = myString & "Extra Notes: " & Cells(myRow, 13) & vbCrLf & vbCrLf
'Dim OutApp As Object
'Dim OutMail As Object
'Set OutApp = CreateObject("Outlook.Appl ication")
'Set OutMail = OutApp.CreateItem(0)
On Error GoTo Problem
' Change the mail address and subject in the macro before you run it.
'' With OutMail
'' .To = "dprogelhof@theapartmentga llery.com; fsturgill@theapartmentgall ery.com"
'' .CC = "shicks@theapartmentgaller y.com"
'' .BCC = ""
'' .Subject = "There is a issue with inspection: " & Cells(6, 3)
'' .Body = myString
'' .Attachments.Add ActiveWorkbook.FullName
'' You can add other files by uncommenting the following line.
'' .Attachments.Add ("C:\test.txt")
'' In place of the following statement, you can use ".Display" to
'' display the mail.
'' .Send
'' End With
Set CD0_Mail = CreateObject("CDO.message" )
Set cdo_config = CreateObject("CDO.Configur ation")
cdo_config.Load = -1
Set smtp_config = cdo_config.Fields
With smtp_config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "APTEMAILSERVER2.mail2.apa rtmentgall ery.net"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item(cdoSMTPAuthenticate) = 1
.Item(cdoSendUserName) = "webmaster"
.Item(cdoSendPassword) = "REnxFexr"
.Update
End With
With CD0_Mail
Set .Configuration = cdo_config
End With
With CD0_Mail
.From= "mgmhicks@ee.com"
.To = "dprogelhof@theapartmentga llery.com; fsturgill@theapartmentgall ery.com"
.CC = "shicks@theapartmentgaller y.com"
.BCC = ""
.Subject = "There is a issue with inspection: " & Cells(6, 3)
.TextBody = myString
'.Attachments.Add ActiveWorkbook.FullName
' You can add other files by uncommenting the following line.
'.Attachments.Add ("C:\test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
.Send
End With
'Set OutMail = Nothing
'Set OutApp = Nothing
Set CD0_Mail = Nothing
Set cdo_config = Nothing
Exit Function
Problem:
MsgBox Err.Description
Exit Function
OM Gang
Dim myString As String
myString = "Item: " & Cells(myRow, 2) & vbCrLf & vbCrLf
myString = myString & "Detail Description: " & Cells(myRow, 3) & vbCrLf & vbCrLf
myString = myString & "Detail Comments: " & Cells(myRow, 4) & vbCrLf & vbCrLf
myString = myString & "Resolution: " & Cells(myRow, 5) & vbCrLf & vbCrLf
myString = myString & "Proposal due Date: " & Cells(myRow, 6) & vbCrLf & vbCrLf
myString = myString & "Who is obtaining?: " & Cells(myRow, 7) & vbCrLf & vbCrLf
myString = myString & "Target Date: " & Cells(myRow, 8) & vbCrLf & vbCrLf
myString = myString & "Date Proposal Received: " & Cells(myRow, 9) & vbCrLf & vbCrLf
myString = myString & "Date of SignOff: " & Cells(myRow, 10) & vbCrLf & vbCrLf
myString = myString & "Date Work Completed: " & Cells(myRow, 11) & vbCrLf & vbCrLf
myString = myString & "Follow Up Date: " & Cells(myRow, 12) & vbCrLf & vbCrLf
myString = myString & "Extra Notes: " & Cells(myRow, 13) & vbCrLf & vbCrLf
'Dim OutApp As Object
'Dim OutMail As Object
'Set OutApp = CreateObject("Outlook.Appl
'Set OutMail = OutApp.CreateItem(0)
On Error GoTo Problem
' Change the mail address and subject in the macro before you run it.
'' With OutMail
'' .To = "dprogelhof@theapartmentga
'' .CC = "shicks@theapartmentgaller
'' .BCC = ""
'' .Subject = "There is a issue with inspection: " & Cells(6, 3)
'' .Body = myString
'' .Attachments.Add ActiveWorkbook.FullName
'' You can add other files by uncommenting the following line.
'' .Attachments.Add ("C:\test.txt")
'' In place of the following statement, you can use ".Display" to
'' display the mail.
'' .Send
'' End With
Set CD0_Mail = CreateObject("CDO.message"
Set cdo_config = CreateObject("CDO.Configur
cdo_config.Load = -1
Set smtp_config = cdo_config.Fields
With smtp_config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "APTEMAILSERVER2.mail2.apa
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item(cdoSMTPAuthenticate)
.Item(cdoSendUserName) = "webmaster"
.Item(cdoSendPassword) = "REnxFexr"
.Update
End With
With CD0_Mail
Set .Configuration = cdo_config
End With
With CD0_Mail
.From= "mgmhicks@ee.com"
.To = "dprogelhof@theapartmentga
.CC = "shicks@theapartmentgaller
.BCC = ""
.Subject = "There is a issue with inspection: " & Cells(6, 3)
.TextBody = myString
'.Attachments.Add ActiveWorkbook.FullName
' You can add other files by uncommenting the following line.
'.Attachments.Add ("C:\test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
.Send
End With
'Set OutMail = Nothing
'Set OutApp = Nothing
Set CD0_Mail = Nothing
Set cdo_config = Nothing
Exit Function
Problem:
MsgBox Err.Description
Exit Function
Set .Configuration = cdo_config
End With
should be
With CDO_Mail
Set .Configuration = cdo_config
End With
OM Gang