hi,
i want to send emails with vba, but i want to use my company email so i studied a lot of stuff about CDO message, but surely i miss something.
this is the code i found
this is the call of the functionCode:Function SendMail(StrFrom As StringStrTO As String, StrSubject As String, StrTextBody As String, Optional StrCC As String, Optional StrBcc As String, Optional StrAttachDoc As String, Optional blnHighPriority As Boolean = False) DIM objMessage As Object Set objMessage = New CDO.Message With objMessage .From = StrFrom .To = StrTO If Len(Trim$(StrCC)) > 0 Then .CC = StrCC End If If Len(StrBcc) > 0 Then .Bcc = StrBcc End If If blnHighPriority Then With .Fields ' for Outlook: .Item(cdoImportance) = cdoHigh .Item(cdoPriority) = cdoPriorityUrgent .Update End With End If .Subject = StrSubject If InStr(UCase(StrTextBody), "<HTML>") Or InStr(UCase(StrTextBody), "</HTML>") Then .HTMLBody = StrTextBody Else .TextBody = StrTextBody End If If Len(StrAttachDoc) > 0 Then .AddAttachment StrAttachDoc End If With .Configuration.Fields .Item(CDO.cdoSMTPServer) = "authsmtp.securemail.pro" .Item(CDO.cdoSMTPServerPort) = 25 .Item(CDO.cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPConnectionTimeout) = 10 .Update End With .Send End With Set objMessage = Nothing End Function
Code:Private Sub SendMailBtn_Click() Call SendMail("diego.maradona@maradona.it", "diegomaradona@yahoo.it", "hello", "lalo") DoCmd.Close acForm, "invio mail" End Sub
i have an errore "account must be authenticated"
i just found the CDO sistem so i have no clue about the error.
ps is it possible to open outlook with the prepared mail instead of sending it?


Problem with cdo message
Reply With Quote

