C# 网页sapx页面调用用户邮箱客户端

 刚接手这个功能总觉得一脸懵逼。以前做的都直接拼接好字符串然后调用邮件接口直接发出其他人。这次的需求是拼接好字符串之后调用用户客户端让发送邮件的人确认数据是否正确再发送出去。虽然听起来很简单,可是到小司机我手里就变得超级难,一路艰辛还是记录下来,如果看答案快点可直接读到最后;

1.第一次百度的答案 System.Diagnostics.Process.Start()

 string sEmailMSG = "mailto:" +HttpUtility.UrlEncode( Emailto) + "?CC=" + HttpUtility.UrlEncode(EmailToCC) + "?subject=" +HttpUtility.UrlEncode( emailTitle) + 
                "&body=" +HttpUtility.UrlEncode( emailBody);

            
          System.Diagnostics.Process.Start(sEmailMSG);

在本地测试完成之后部署到服务器,之后完全失效这个方法。一点反映都没有,当然你百度的话,很多就百度到这个方法,你也可能跟我一样的入坑了。后来看了,System.Diagnostics.Process.Start()方法好像调用本地的程序。也就是服务器会自己调用服务器端的客户端,所以到用户那里就失效了。如果您也跟我一样用aspx的后台调用客户端,B/s的话把这个方法抛弃了吧。


2.在页面上写a标签,用href来实现<a href=mailto:2553421984@qq.com>send email</a>

这个方法能在服务器上调起邮箱客户端。到这里感觉还是好幸福的,至少看到希望了。但是href链接的数据怎么从后台绑定到href里呢,又脑子死路了,用<% Gethtml() >来在页面上,我当初用href=<% Gethtml()>悲催这样写是谁教我的,想想都好笑。反正一句话部行


3.正确的绑定方式

string sEmailMSG = "mailto:" +HttpUtility.UrlEncode( Emailto) + "?CC=" + HttpUtility.UrlEncode(EmailToCC) + "?subject=" +HttpUtility.UrlEncode( emailTitle) + 
                "&body=" +HttpUtility.UrlEncode( emailBody);


            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.open ('" + sEmailMSG + "')</script>");

好吧重点是其实不需要a标签也能实现,直接用page.ClientScript.RegisterSartupScript(this.GetType(),"","<Script>window.open(sEmailMSG )"</scrpt>)就这样直接弹出调用客户端就好,很简单对吧。







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是通过GigE协议接收GigE相机图像数据的示例代码,使用了GigE Vision SDK: ```c++ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <GevApi.h> #include <SapX11Util.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #define MAX_NETIF 8 #define MAX_CAMERAS_PER_NETIF 32 #define MAX_CAMERAS (MAX_NETIF * MAX_CAMERAS_PER_NETIF) #define NUM_BUF 4 #define TIMEOUT 1000 int main(int argc, char* argv[]) { // Initialize the GigE Vision API if (GevApiInitialize() != GEVLIB_OK) { printf("Error: GevApiInitialize() failed!\n"); exit(EXIT_FAILURE); } // Get all available network interfaces GEV_DEVICE_INTERFACE pNetIF[MAX_NETIF]; uint32_t numInterfaces = 0; if (GevGetInterfaces(pNetIF, MAX_NETIF, &numInterfaces) != GEVLIB_OK) { printf("Error: GevGetInterfaces() failed!\n"); exit(EXIT_FAILURE); } // Get all available cameras on the network GEV_CAMERA pCamera[MAX_CAMERAS]; uint32_t numCameras = 0; for (uint32_t i = 0; i < numInterfaces; i++) { if (GevGetCameraList(pNetIF[i].szInterfaceName, GEV_PROTOCOL_FORCEIP, pCamera + numCameras, MAX_CAMERAS_PER_NETIF, &numCameras) != GEVLIB_OK) { printf("Error: GevGetCameraList() failed on interface %s!\n", pNetIF[i].szInterfaceName); exit(EXIT_FAILURE); } } // Open a connection to the first camera found GEV_CAMERA_HANDLE hCamera = NULL; if (numCameras > 0) { if (GevOpenCamera(&pCamera[0], GEV_EXCLUSIVE_MODE, &hCamera) != GEVLIB_OK) { printf("Error: GevOpenCamera() failed!\n"); exit(EXIT_FAILURE); } } else { printf("Error: no camera found on the network!\n"); exit(EXIT_FAILURE); } // Start the acquisition engine if (GevStartImageTransfer(hCamera, NUM_BUF) != GEVLIB_OK) { printf("Error: GevStartImageTransfer() failed!\n"); exit(EXIT_FAILURE); } // Allocate buffers for incoming images uint32_t payloadSize = 0; if (GevGetPayloadSize(hCamera, &payloadSize) != GEVLIB_OK) { printf("Error: GevGetPayloadSize() failed!\n"); exit(EXIT_FAILURE); } void* pBuffer[NUM_BUF]; for (uint32_t i = 0; i < NUM_BUF; i++) { pBuffer[i] = malloc(payloadSize); if (pBuffer[i] == NULL) { printf("Error: failed to allocate buffer!\n"); exit(EXIT_FAILURE); } if (GevRegisterImageBuffer(hCamera, pBuffer[i], payloadSize, i) != GEVLIB_OK) { printf("Error: GevRegisterImageBuffer() failed!\n"); exit(EXIT_FAILURE); } } // Create a window to display the image Display* pDisplay = XOpenDisplay(NULL); if (pDisplay == NULL) { printf("Error: XOpenDisplay() failed!\n"); exit(EXIT_FAILURE); } Window window = XCreateSimpleWindow(pDisplay, DefaultRootWindow(pDisplay), 0, 0, 640, 480, 0, 0, 0); XSelectInput(pDisplay, window, ExposureMask | KeyPressMask); XMapWindow(pDisplay, window); while (true) { // Wait for an image to be received GEV_BUFFER_OBJECT pBufferObj = { 0 }; if (GevWaitForNextImage(hCamera, &pBufferObj, TIMEOUT) == GEVLIB_OK) { // Get the image data and display it char* pData = (char*)pBuffer[pBufferObj.context]; int width = pBufferObj.w; int height = pBufferObj.h; XImage* pImage = XCreateImage(pDisplay, DefaultVisual(pDisplay, 0), DefaultDepth(pDisplay, 0), ZPixmap, 0, pData, width, height, 32, 0); XEvent event; while (XPending(pDisplay)) { XNextEvent(pDisplay, &event); if (event.type == Expose) { XPutImage(pDisplay, window, DefaultGC(pDisplay, 0), pImage, 0, 0, 0, 0, width, height); } } } } // Cleanup for (uint32_t i = 0; i < NUM_BUF; i++) { GevFreeImageBuffer(hCamera, pBuffer[i]); free(pBuffer[i]); } XCloseDisplay(pDisplay); GevStopImageTransfer(hCamera); GevCloseCamera(&hCamera); GevApiUninitialize(); return EXIT_SUCCESS; } ``` 注意:这只是一个示例代码,需要根据具体的相机型号和网络环境进行适当的修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值