Sending out Automate email. (1 Viewer)

Meehphill

Registered User.
Local time
Today, 12:43
Joined
May 9, 2013
Messages
18
HI everyone !

I'm been on this for a fews days...I use a macro (SendObject), which works, but it requires Us, or someone to go into Outlook to click on send.

I'm new to vba, do I have to code something on outlook to send automatcially?
or is this an access thing? Please help..

Thanks
 

Meehphill

Registered User.
Local time
Today, 12:43
Joined
May 9, 2013
Messages
18
Rural Guy,

So copy this code: Into mSoutlook? I"m confused...when reading about CDO.

Dim oEMail As New CDONTS.EMail

oEMail.From "anyname@anydomain.com"
oEMail.To "youremail@yourdomain.com"
oEMail.BodyFormat = CdoBodyFormatText
oEMail.Body = "Insert some useful text here"
oEMail.Importance = CdoHigh
oEMail.AttachFile "C:\filename.txt"
oEMail.Send
 

RuralGuy

AWF VIP
Local time
Today, 13:43
Joined
Jul 2, 2005
Messages
13,826
You're missing some stuff.
Code:
Public Function SimpleSendEMailWithCDO() As Boolean

   Dim iCfg As Object
   Dim iMsg As Object

   On Error GoTo SimpleSendEMailWithCDO_Error

   Set iCfg = CreateObject("CDO.Configuration")
   Set iMsg = CreateObject("CDO.Message")

   With iCfg.Fields

      ' Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
      ' Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.so.centurytel.net"
      ' cdoBasic 1
      ' Use basic (clear-text) authentication.
      ' The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ctr69265"
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "c9j56a5c"
      .Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "MaltShoppe <System@MaltShoppe.Net>"
      ' 'Use SSL for the connection (False or True)
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
      ' 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

      .Update
   End With

   With iMsg
      .configuration = iCfg
      .Subject = "Your Subject"
      .To = "YourDestination@SomeISP.net"
      ' .Cc = ""
      ' .Bcc = ""
      .TextBody = "See attachment"
      .AddAttachment CurrentProject.Path & AttachFile
      .Send
   End With

   Set iMsg = Nothing
   Set iCfg = Nothing
   SimpleSendEMailWithCDO = True
   
SimpleSendEMailWithCDO_Exit:
   On Error GoTo 0
   Exit Function

SimpleSendEMailWithCDO_Error:

   MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SimpleSendEMailWithCDO of Module basCDO"
   SimpleSendEMailWithCDO = False
   Resume SimpleSendEMailWithCDO_Exit
   
End Function
 

Meehphill

Registered User.
Local time
Today, 12:43
Joined
May 9, 2013
Messages
18
I'm sorry about this RuralGuy,

Do I copy & paste this code in Access, but where? Modules? or Outlook...a little conufused, since i'm not a VBA person, yet...but i'm learning..

Phill

Can u instruct me, give me little more details...step by step perhaps?
 

RuralGuy

AWF VIP
Local time
Today, 13:43
Joined
Jul 2, 2005
Messages
13,826
It goes in a Standard Module along with the rest of the procedures. I have to go to a meeting and will gone for several hours. I'll check back in when I get back. Maybe now the link I supplied will make a little more sense.
 

Users who are viewing this thread

Top Bottom