Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

send email internally with no password using SmtpClient

A corporate network has an email account where no authentication is required to send emails internally

I'm a little unsure how its done as the SmtpClient needs authentication (as I can see)

They gave me a code sample which works on their end


.Item(cdoSendUsingMethod) = cdoSendUsingPort

.Item(cdoSMTPServerPort) = 25

.Item(cdoSMTPServer) = "mail.theircorp.com" 

.Item(cdoSMTPAuthenticate) = cdoBasic

.Item(cdoSendUserName) = "nouser@theircorp.com"

.Item(cdoSendPassword) = ""

.Item(cdoSendEmailAddress) = "nouser@theircorp.com"

Open in new window


But I assume this is old tech.


How would I achieve this using SmtpClient
Avatar of Alex
Alex
Flag of United Kingdom of Great Britain and Northern Ireland image

Use powershell


#Send mail function
Function send_mail([string]$message,[string]$subject) {
    $emailFrom = "ADReports@company.com"
    $emailTo = "alex.green@company.com"
    $smtpServer = "exchangeserver"
    Send-MailMessage -SmtpServer $smtpServer -To $emailTo -From $emailFrom -Subject $subject -Body $message -BodyAsHtml -Priority High
}

Open in new window




Avatar of websss

ASKER

thanks, I need to do this in C# though

Oh,


I'm out in that case, sorry :(


I unfortunately didn't see the Tags of .NET etc.


Regards

Alex

ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial