乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 28|回复: 3

[编程交流] 使用visu打开并发送电子邮件

[复制链接]

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 09:10:44 | 显示全部楼层 |阅读模式
几年前,有人写了一些代码,可以打开一个电子邮件表单并在上面留言。我想用它或类似的方式打开一封包含消息的电子邮件(不一定发送)
我喜欢做的是在消息体中放置文件路径,其中包含用户所在的当前dwg的dwg名称。这是迄今为止最简单的一点。困难在于打开电子邮件。
这是我的代码-我使用Lotus notes,因此我尝试使其适合Lotus notes而不是Outlook。
如果你能帮忙,谢谢你!
 
  1. (defun C:CreateMail ()
  2. ; Who's going to get the mail
  3. (setq recipients_list (list "[email="holsinf@stig.co.nz"]holsinf@stig.co.nz[/email]"))
  4. ; What is the subject
  5. (setq subject "Subject of the mail")
  6. ; What is the body
  7. (setq body "Body of the mail")
  8. ; What are the attachments
  9. (setq attachments_list (list "MyDrawing.dwg"))
  10. ;;;(create-email recipients_list subject body attachments_list 1) ; Do send this mail immediately
  11. (create-email recipients_list subject body attachments_list 0) ; Do not yet send this mail
  12. (princ)
  13. )
  14. (defun create-email (recipients_list
  15. subject body
  16. attachments_list email_send
  17. / acadapp
  18. acaddoc outlookapp
  19. mail_object recipients_collection
  20. attachments_collection
  21. temp ret
  22. item cadz3d_function
  23. )
  24. ;; Load the extended AutoLISP functions and ActiveX support
  25. (vl-load-com)
  26. ;; Get the application and current document objects
  27. (setq acadapp (vlax-get-acad-object)
  28. acaddoc (vlax-get-property acadapp 'activedocument)
  29. )
  30. ;; Get the existing outlook application object
  31. (if
  32. (or (= (setq outlookapp (vl-catch-all-apply 'vlax-get-object (list
  33. "Lotus Notes.Application")));
  34. nil
  35. )
  36. (/= (type outlookapp) 'vla-object)
  37. )
  38. (progn (alert (strcat
  39. "Microsoft Outlook must already be running\n"
  40. "to create and send the email. This will be\n"
  41. "improved in future versions.\n\n"
  42. "Please start Microsoft Outlook and then close\n"
  43. "this dialog box to create the email."
  44. )
  45. )
  46. (setq outlookapp (vl-catch-all-apply 'vlax-get-object (list
  47. "Lotus notes.Application")))
  48. )
  49. )
  50. (if (= (type outlookapp) 'vla-object)
  51. (if ;; Create new email object
  52. (setq mail_object (vlax-invoke-method outlookapp 'createitem 0))
  53. (if ;; Get the recipients collection
  54. (setq recipients_collection (vlax-get-property mail_object 'recipients))
  55. (progn
  56. ;; Add the recipients properties to the email
  57. (foreach item recipients_list
  58. (if (= (type item) 'str)
  59. (vlax-invoke-method recipients_collection 'add item)
  60. )
  61. )
  62. ;; Add the subject properties to the email
  63. (if (= (type subject) 'str)
  64. (vlax-put-property mail_object 'subject subject)
  65. )
  66. ;; Add the body properties to the email
  67. (if (= (type body) 'str)
  68. (vlax-put-property mail_object 'body body)
  69. )
  70. ;; Add the attachements properties to the email
  71. (if
  72. (and (vl-consp attachments_list)
  73. (setq attachments_collection (vlax-get-property mail_object
  74. 'attachments))
  75. )
  76. (foreach item attachments_list
  77. (if (and (setq temp (findfile item)) (vl-file-systime temp))
  78. (vlax-invoke-method attachments_collection 'add temp)
  79. )
  80. )
  81. )
  82. ;; If the email_send equals 1 and the recipients_list, subject, and body
  83. ;;;were passed to the
  84. ;; function then send the email, otherwise display the email for the user
  85. ;;;to finish
  86. (if (and (= email_send 1)
  87. (vl-consp recipients_list)
  88. ;;;subject
  89. ;;;body
  90. (/= subject "")
  91. (/= body "")
  92. )
  93. (vlax-invoke-method mail_object 'send)
  94. (vlax-invoke-method mail_object 'display)
  95. )
  96. (setq ret t)
  97. )
  98. (princ "\nCould not get the recipients collection from the new mail item")
  99. )
  100. (princ "\nCould not create a new mail item through Outlook")
  101. )
  102. (princ "\nCould not create a new instance of Outlook")
  103. )
  104. ;; Release the objects
  105. (if (and (= (type attachments_collection) 'vla-object)
  106. (= (vlax-object-released-p attachments_collection) nil)
  107. )
  108. (vlax-release-object attachments_collection)
  109. )
  110. (if (and (= (type recipients_collection) 'vla-object)
  111. (= (vlax-object-released-p recipients_collection) nil)
  112. )
  113. (vlax-release-object recipients_collection)
  114. )
  115. (if (and (= (type mail_object) 'vla-object) (= (vlax-object-released-p
  116. mail_object) nil))
  117. (vlax-release-object mail_object)
  118. )
  119. (if (and (= (type outlookapp) 'vla-object) (= (vlax-object-released-p
  120. outlookapp) nil))
  121. (vlax-release-object outlookapp)
  122. )
  123. (if (and (= (type acaddoc) 'vla-object) (= (vlax-object-released-p
  124. acaddoc) nil))
  125. (vlax-release-object acaddoc)
  126. )
  127. (if (and (= (type acadapp) 'vla-object) (= (vlax-object-released-p
  128. acadapp) nil))
  129. (vlax-release-object acadapp)
  130. )
  131. (princ)
  132. ret
  133. );defun
回复

使用道具 举报

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 09:32:53 | 显示全部楼层
嗨,小鱼,
 
你找到解决方法了吗。我有一些可能有用的东西。。。
回复

使用道具 举报

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 09:51:59 | 显示全部楼层
谢谢Waybos-不,我没有。然而,我们的办公室正在抛弃Lotus Notes,转而使用Ms Outlook,所以现在这无关紧要。不过,谢谢你的回复
旧金山
回复

使用道具 举报

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 10:15:27 | 显示全部楼层
在命令行中试试这个
开始
见解exe/c ipm。注/mjohnsmith@emailaddress.com
看看会发生什么。
搜索outlook的命令行开关。那么你也会想
搜索“mailto URL,outlook”
享受
WB公司
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 05:21 , Processed in 0.500930 second(s), 71 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表