mail server
-
sorry for asking this question for the hundredth time but I've never got an answer how to get the MX server. I want to make a program that can send an email from you computer and for each mail address I have to write the SMTP server. I want a function that get's it automatically. Thankx gabby
-
sorry for asking this question for the hundredth time but I've never got an answer how to get the MX server. I want to make a program that can send an email from you computer and for each mail address I have to write the SMTP server. I want a function that get's it automatically. Thankx gabby
If you are using MAPI try this. You should have a profile name supplied.
HRESULT GetServerName(LPSTR rszProfileName) { HRESULT hRes = S_OK; LPPROFADMIN pAdminProfiles = NULL; LPSERVICEADMIN pSvcAdmin = NULL; LPPROFSECT pGlobalProfSect = NULL; LPSPropValue pProps = NULL; // Get a Profile admin object if ( FAILED ( hRes = MAPIAdminProfiles ( 0L, &pAdminProfiles ) ) ) return hRes ; // Get a ServiceAdmin object if ( FAILED ( hRes = pAdminProfiles -> AdminServices ( rszProfileName, NULL, 0L, // Your app's window handle 0L, &pSvcAdmin ) ) ) return hRes ; // Get the Global Profile Section by calling // IServiceAdmin::OpenProfileSection use pbGlobalProfileSectionGuid // defined in EDKMDB.H as the entry ID to request // The default return is an IProfSect interface. if ( FAILED ( hRes = pSvcAdmin -> OpenProfileSection ( (LPMAPIUID)pbGlobalProfileSectionGuid, NULL, 0L, &pGlobalProfSect ) ) ) return hRes ; // Call HrGetOneProp to get PR_PROFILE_HOME_SERVER if ( FAILED ( hRes = HrGetOneProp ( pGlobalProfSect, PR_PROFILE_HOME_SERVER, &pProps ) ) ) return hRes ; CString m_strServerName = pProps -> Value.lpszA ; if ( NULL != pAdminProfiles ) pAdminProfiles -> Release (); if ( NULL != pSvcAdmin ) pSvcAdmin -> Release ( ); if ( NULL != pGlobalProfSect ) pGlobalProfSect -> Release ( ); if ( NULL != pProps ) MAPIFreeBuffer ( &pProps ); pSvcAdmin = NULL; pGlobalProfSect = NULL; pProps = NULL; pAdminProfiles = NULL; // Return the HRESULT to the calling function return hRes; }
The above code might have some variables not declared. Pls check it out before using. Muthukumar.V Home: WWW.CoderSource.Net -
sorry for asking this question for the hundredth time but I've never got an answer how to get the MX server. I want to make a program that can send an email from you computer and for each mail address I have to write the SMTP server. I want a function that get's it automatically. Thankx gabby
If you're wanting to write your own SMTP server application I recommend reading RFC 2821. In regards to your question about how to obtain an MX record for a particular domain (example: yahoo.com, hotmail.com, etc...), you will need to need to query DNS. A good place to start to would be to use google.com, or better yet, if you're just looking for a quick solution, try this link. http://www.codeguru.com/Cpp/I-N/internet/dns/article.php/c6163/ Regards, John
-
sorry for asking this question for the hundredth time but I've never got an answer how to get the MX server. I want to make a program that can send an email from you computer and for each mail address I have to write the SMTP server. I want a function that get's it automatically. Thankx gabby
Your best bet is to relay through an existing mail server, just like Outlook Express does. But if you really need to do it directly, and expect to run on Windows 2000 onwards, then checkout the DNS API, DnsQuery specifically. Otherwise you'll have to look up the DNS spec, find out how to locate your local DNS server and do the query manually. Paul