Hi @Lalitha Subramanian
I understand that you are trying to use email to send and receive emails via code, but authentication fails and mail not getting sent. Now you are trying a way to disable 2FA for a list of IP addresses which doesn't belong to a subnet range or any other range.
You can try to achieve this by configuring a conditional access policy in Azure.
You can define a conditional access policy by mentioning IP addresses range which should not prompt for MFA while accessing Azure resources. You can configure this in Named locations in Conditional access policy. Once you create Named locations you can use this Named location in the conditional access policy that you create.
You can follow below article to configure CA policy with named locations using network IP ranges for MFA prompts.
https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-assignment-network
Let me know if you have any further questions.
If this answers your query, do click Accept Answer
and Yes
.